Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Projucer cmdline cannot be run without X11 #422

Closed
umlaeute opened this issue Sep 24, 2018 · 8 comments
Closed

Projucer cmdline cannot be run without X11 #422

umlaeute opened this issue Sep 24, 2018 · 8 comments

Comments

@umlaeute
Copy link

umlaeute commented Sep 24, 2018

Trying to run Projucer (in cmdline mode) on a headless machine (without any display-server) fails.

On Linux/amd64 (distro: Debian/buster) with Projucer from today's develop branch (dbb1345) i get:

$ cd JUCE/extras/Projucer/Builds/LinuxMakefile/build
$ ./Projucer -resave ../../../../UnitTestRunner/UnitTestRunner.jucer 
JUCE v5.3.2
No protocol specified
No protocol specified
Failed to connect to the X Server.
$

Our use-case is continuous-integration, where we build JUCE-projects on every push to our git-repository.
Our git repository follows best-practice, and does not include any generated code, so the only build-files are the .jucer projects (no Makefiles, XCode, VS-Projects in the repository), and the actual build-system needs to be generated on-the-fly using Projucers -resave` command.

Now I understand that Projucer is mainly an IDE to be used with it's fancy GUI.
However, when doing CI-builds, we must automate everything, and don't have a GUI available.

Since running Projucer -resave doesn't actually open up any window, I would have expected that it does not require a full display server.

The simplest way I found for reproducing this (assuming you are working in a running X11-session) is to ssh into the same machine with a different account (and of course have X-forwarding disabled):

$ ssh root@localhost
# ./Projucer -resave ../../../../UnitTestRunner/UnitTestRunner.jucer 
@peterrudenko
Copy link

I've faced the same problem when setting up CI, and one possible workaround is to use virtual framebuffer:
xvfb-run -a bash -c 'command-line-of-yours'

@umlaeute
Copy link
Author

umlaeute commented Oct 6, 2018

that's what i'm doing right now to circumvent the problem.

i still don't see why i have to install a fake X-server with all it's dependencies, just because Projucer is unable to operate on the cmdline without trying to spawn a window (which it never opens)

@laserbat
Copy link

This is a serious issue and it's really sad to see it being unnoticed by developers. I'm trying to package a JUCE based app for void linux and it's very ugly because of this bug :(

@McMartin
Copy link
Contributor

@laserbat If you have a .jucer project file, you can use Jucer2Reprojucer from FRUT (I'm the author) to convert it to a CMakeLists.txt file and then use CMake to build.

@chevdor
Copy link

chevdor commented Nov 14, 2019

I ran into this issue on a recent Ubuntu with X11 / Gnome installed and fully functional.
This is fortunately easy to fix (maybe the info can be added to the doc).

Here is a one-liner:
echo "export GDK_BACKEND=x11" >> ~/.bashrc && source ~/.bashrc

Note, this will fix only your current shell. If you have other open shells, you probably want to close and re-open them. After rebooting your system, all shells will be fine however.

After doing that, you will be able to start Projucer from the JUCE folder with ./Projucer and it should work all fine.

@kunitoki
Copy link

kunitoki commented Mar 11, 2020

i have the same issue on my own app. the application can't run from bash if it's not under x11, any news if this could be addressed ?

@kunitoki
Copy link

I tried this and it's working nicely.

diff --git a/juce/modules/juce_gui_basics/native/juce_linux_X11.cpp b/juce/modules/juce_gui_basics/native/juce_linux_X11.cpp
index a2ceb67074d2b2b9c8988b2dbdb1f7737d8d8336..82907489ce4fd5222aa6c5219d6c4fc58b070d2f 100644
--- a/juce/modules/juce_gui_basics/native/juce_linux_X11.cpp
+++ b/juce/modules/juce_gui_basics/native/juce_linux_X11.cpp
@@ -149,14 +149,16 @@ XWindowSystem::~XWindowSystem() noexcept
 
 ::Display* XWindowSystem::displayUnref() noexcept
 {
-    jassert (display != nullptr);
-    jassert (displayCount.get() > 0);
-
-    if (--displayCount == 0)
+    if (display)
     {
-        destroyXDisplay();
-        XCloseDisplay (display);
-        display = nullptr;
+        jassert (displayCount.get() > 0);
+
+        if (--displayCount == 0)
+        {
+            destroyXDisplay();
+            XCloseDisplay (display);
+            display = nullptr;
+        }
     }
 
     return display;
@@ -168,7 +170,7 @@ void XWindowSystem::initialiseXDisplay() noexcept
     if (display == nullptr)
     {
         Logger::outputDebugString ("Failed to connect to the X Server.");
-        Process::terminate();
+        return;
     }
 
     // Create a context to store user data associated with Windows we create
@@ -223,11 +225,14 @@ void XWindowSystem::initialiseXDisplay() noexcept
 
 void XWindowSystem::destroyXDisplay() noexcept
 {
-    ScopedXLock xlock (display);
-    XDestroyWindow (display, juce_messageWindowHandle);
-    juce_messageWindowHandle = 0;
-    XSync (display, True);
-    LinuxEventLoop::unregisterFdCallback (XConnectionNumber (display));
+    if (display)
+    {
+        ScopedXLock xlock (display);
+        XDestroyWindow (display, juce_messageWindowHandle);
+        juce_messageWindowHandle = 0;
+        XSync (display, True);
+        LinuxEventLoop::unregisterFdCallback (XConnectionNumber (display));
+    }
 }
 
 JUCE_IMPLEMENT_SINGLETON (XWindowSystem)

@tpoole
Copy link
Member

tpoole commented Mar 11, 2022

As of recent versions of JUCE the Projucer should not need an X server to run the command line, although it will need the various X development packages to build.

@tpoole tpoole closed this as completed Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants