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

2.1: [BUG] Not working with both GTK3 and JavaFX #14

Closed
alt-grr opened this issue Feb 13, 2016 · 60 comments
Closed

2.1: [BUG] Not working with both GTK3 and JavaFX #14

alt-grr opened this issue Feb 13, 2016 · 60 comments

Comments

@alt-grr
Copy link

alt-grr commented Feb 13, 2016

After adding support for GTK3, I have same bug on startup as when using SWT:

(java:2033): GLib-GObject-WARNING **: cannot register existing type 'GdkDisplayManager'

(java:2033): GLib-CRITICAL **: g_once_init_leave: assertion 'result != 0' failed

(java:2033): GLib-GObject-CRITICAL **: g_object_new: assertion 'G_TYPE_IS_OBJECT (object_type)' failed

I don't know I you can fix this, so please add option for disabling support for GTK3.

@dorkbox
Copy link
Owner

dorkbox commented Feb 13, 2016

Hm, I have some ideas on how to do that.

@alt-grr
Copy link
Author

alt-grr commented Feb 13, 2016

Ideas for fix, or ideas for option for disabling use of GTK3? : ]

@alt-grr
Copy link
Author

alt-grr commented Feb 13, 2016

I found that

It's possible you're hitting a situation where GTK 2 libraries have already been loaded

@dorkbox
Copy link
Owner

dorkbox commented Feb 13, 2016

For forcing the version of GTK to try. What happens if you set GtkSupport.CREATE_EVENT_LOOP = false ?

@alt-grr
Copy link
Author

alt-grr commented Feb 13, 2016

Same message as above + INFO dorkbox.systemTray.SystemTray - Successfully Loaded: App + segmentation fault for Java process.

So still not better 😞

@alt-grr
Copy link
Author

alt-grr commented Feb 13, 2016

Problematic frame:
# C  [libgdk-3.so.0+0x2d970]  gdk_display_manager_get_default_display+0x0

@dorkbox
Copy link
Owner

dorkbox commented Feb 13, 2016

Hm. SWT likely already loads GTK2 - Let me think about detecting if GTK2 is already loaded

@alt-grr
Copy link
Author

alt-grr commented Feb 13, 2016

But I'm not loading SWT on Linux. I tried using it in the past, but same error occurred, so I resigned.

@dorkbox
Copy link
Owner

dorkbox commented Feb 13, 2016

So you're getting this error on Linux? (ubuntu 15.10?)

@alt-grr
Copy link
Author

alt-grr commented Feb 13, 2016

Just add the option for disabling detection of GTK3 and it will be fine.

So you're getting this error on Linux? (ubuntu 15.10?)

Yes.

@alt-grr
Copy link
Author

alt-grr commented Feb 13, 2016

Ok, if I remove JavaFX from test app (new library with GTK3 support), then that errors are not shown. But icon in tray is also not visible.

@dorkbox
Copy link
Owner

dorkbox commented Feb 13, 2016

Is it loading the AppIndicator library?

@alt-grr
Copy link
Author

alt-grr commented Feb 13, 2016

Sorry, my bad - everything works in that case.

@alt-grr
Copy link
Author

alt-grr commented Feb 13, 2016

So the problem arise when using both GTK3 and JavaFX.

@dorkbox
Copy link
Owner

dorkbox commented Feb 13, 2016

Ahh, it's a JavaFX thing?

@dorkbox
Copy link
Owner

dorkbox commented Feb 13, 2016

That makes a LOT more sense, because I can detect if JavaFX is in use and switch to GTK2 (there will be warnings if libappindicator1 is not present though).

I'll still add an GTK version override though

@alt-grr
Copy link
Author

alt-grr commented Feb 13, 2016

I think that JavaFX loads some GTK libraries and it's causing that problems.

That makes a LOT more sense, because I can detect if JavaFX is in use and switch to GTK2 (there will be warnings if libappindicator1 is not present though).
I'll still add an GTK version override though

Thanks 😄

@alt-grr alt-grr changed the title 2.1: [BUG] Not working with GTK3 2.1: [BUG] Not working with GTK3 and JavaFX Feb 13, 2016
@alt-grr alt-grr changed the title 2.1: [BUG] Not working with GTK3 and JavaFX 2.1: [BUG] Not working with both GTK3 and JavaFX Feb 13, 2016
@alt-grr
Copy link
Author

alt-grr commented Feb 13, 2016

As a side note, in the past I tried to force using GTK2 by SWT, but that then caused problems with JavaFX 😠

But your library in version 1.12, when it still used GTK2, was not causing any problems for me. So just conditionally switching to previous behaviour should work 🆗

@dorkbox
Copy link
Owner

dorkbox commented Feb 13, 2016

I'm guessing now that SWT (GTK2), JavaFX (GTK2), and SystemTray (GTK2/GTK3) -- and they all hate each other. I think I'll change out the event_loop i use, so that will always run (SWT fixed issues they had with nested event loops, which is why i could remove the SWT detection), but it seems that my event loop should always run.

@dorkbox
Copy link
Owner

dorkbox commented Feb 13, 2016

(that might be a confusing comment...)

@alt-grr
Copy link
Author

alt-grr commented Feb 13, 2016

SWT (GTK2), JavaFX (GTK2), and SystemTray (GTK2/GTK3) -- and they all hate each other.

Currently, I'm loading SWT conditionally, only on Windows. But in that case, I'm not loading your library - I use it only on Linux. So forget about SWT 😉 This was only the example of similar error messages.

(but I still have test program that I can run on Windows, so I could report issue #13 )

I confirmed that JavaFX uses, and will be using, GTK2. So, if your library is trying to load GTK3, then we see that problems...

@dorkbox
Copy link
Owner

dorkbox commented Feb 13, 2016

Yea, i'm going to leave out auto-detection, since that is just too tricky. It will just be a boolean you set on startup.

@alt-grr
Copy link
Author

alt-grr commented Feb 13, 2016

🆗
And also add documentation "when you want to set this boolean", so people will not adding duplicated issues.

@dorkbox
Copy link
Owner

dorkbox commented Feb 13, 2016

:) yea, i will - just uploaded 2.2 to maven + github, can you try that out?

@alt-grr
Copy link
Author

alt-grr commented Feb 13, 2016

I tried using version 2.3 and it works (even without forcing GTK2 - do you detecting JavaFX?), but there still issues with shutting down app. I'm using code:

systemTray.shutdown();
Platform.exit(); // JavaFX

and then, depending on app and/or that if I started SystemTray before or after starnig JavaFX, gives me that results:

  1. calling systemTray.shutdown() (from listener thread) just hangs entire app, without even closing opened windows
  2. calling systemTray.shutdown() (from listener thread) closes app windows, but app still hangs, and there are some error mesages:
(java:2716): GLib-CRITICAL **: Source ID 39 was not found when attempting to remove it
(java:2716): GLib-CRITICAL **: Source ID 38 was not found when attempting to remove it

Reversing order of calling systemTray.shutdown() and Platform.exit() doesn't changing much.
Exactly results are semi-randomly, so maybe its' some race condition there.

@dorkbox
Copy link
Owner

dorkbox commented Feb 13, 2016

I actually found a type leftover from when I was testing -- which might be why it's working now. Shutdown should work -- i'll investigate

@alt-grr
Copy link
Author

alt-grr commented Feb 13, 2016

Ah, so you accidentally hardcoded use of GTK2 - I see 😃

Shutdown worked correctly in 1.12, even with JavaFX.

@dorkbox
Copy link
Owner

dorkbox commented Feb 13, 2016

wow. i just noticed that I didn't use .shutdown() in my test example. I think the problem might have been that the dispatch thread was 'interrupting' itself, so anything else in that thread invocation would get ignored.

Try version 2.6 (i just uploaded it to maven + git)

@dorkbox
Copy link
Owner

dorkbox commented Feb 13, 2016

At first glance -- it appears that when I shutdown GTK, that also shutsdown the same GTK that JavaFX uses. What might be possible (I'll check with this later), is that there is another boolean that affects the shutdown procedure. I'm not sure the best way to approach this...

@dorkbox
Copy link
Owner

dorkbox commented Feb 13, 2016

Because either I shutdown GTK or javaFX shutsdown GTK -- we end up in a hung state, where which ever happens fist -- leaves the other unresponsive.

@alt-grr
Copy link
Author

alt-grr commented Feb 13, 2016

One thing I noticed -- is that if you close whatever window is open, the system tray stops responding to events.

That's excepted behaviour - in JavaFX, by default, closing last window shutdown entire app.

What might be possible (I'll check with this later), is that there is another boolean that affects the shutdown procedure. I'm not sure the best way to approach this...

I suggest to not adding another boolean, but instead renaming current boolean to something like JAVAFX_COMPABILITY_MODE, and leaving the rest of the story hidden as implementation detail.

@dorkbox
Copy link
Owner

dorkbox commented Feb 14, 2016

Give 2.10 a try. I've done two things.

  • I figured out a pretty reliable way to discover on startup if javaFX has been initialized. JavaFX always starts the GTK main loop, which I now check (and do things differently). This should be 100% reliable, but just in case...
  • Added JAVAFX_COMPABILITY_MODE if the autodetection fails.

I also added a JavaFX test application as well - the only thing different you'll need to do is call Platform.exit() inside of the quit callback if you want that to shutdown JavaFX as well.

If JavaFX main window is closed, the SystemTray will also close. This is necessary since JavaFX kills GTK and it will hang (as previously observed).

@alt-grr
Copy link
Author

alt-grr commented Feb 14, 2016

2.10? I tested 2.8 and autodetection of JavaFX and shutdown works flawlessly! Good job 😃

What are the new changes in 2.10?

@alt-grr alt-grr closed this as completed Feb 14, 2016
@dorkbox
Copy link
Owner

dorkbox commented Feb 14, 2016

Also - I've been testing SWT, and so far - no luck.

@dorkbox
Copy link
Owner

dorkbox commented Feb 14, 2016

2.10 is the addition of JAVAFX_COMPABILITY_MODE.

A lot of builds are going, trying to get SWT working... Out of curiosity - do you use the SWT systemtray, when you're using SWT?

@alt-grr
Copy link
Author

alt-grr commented Feb 14, 2016

2.10 is the addition of JAVAFX_COMPABILITY_MODE.

Ok, so I can just update to newest-newest version then 😉

do you use the SWT systemtray, when you're using SWT?

Yes, but only system tray component, and only on Windows, when I don't use your library (it still currently does not works on windows anyway, heh). So I don't care about possible incompatibilities.

@dorkbox
Copy link
Owner

dorkbox commented Feb 14, 2016

Ok, so I can just update to newest-newest version then

Yea :)

it still currently does not works on windows anyway

I'll get on that right now, since the idea is for SystemTray to work on everything.

@dorkbox
Copy link
Owner

dorkbox commented Feb 14, 2016

Alright, 2.11 is release, three changes were made.

  • Windows works again
  • Reverted the checked exceptions back to unchecked exceptions
  • JavaFX is checked to see if it's loaded before adding shutdown hooks (for when javaFX isn't being used, it won't try to initialize javaFX when it adds the hook)

@dorkbox
Copy link
Owner

dorkbox commented Feb 14, 2016

Arrgh - i test it (it works), push the build to maven and test again in my main app and ... it doesn't work.

@alt-grr
Copy link
Author

alt-grr commented Feb 14, 2016

I'm satisfied with 2.10 release, you don't need to be in a hurry 😉

@alt-grr
Copy link
Author

alt-grr commented Aug 14, 2016

@dorkbox This AGAIN no longer works on Ubuntu 16.04
Tested with versions 2.12 and 2.20
Both relying on autodetection, and setting compatibility mode manually doesn't work.

@dorkbox
Copy link
Owner

dorkbox commented Aug 14, 2016

Awesome!! :(

I'll look into it. Sadly, not right away as I'm in the middle of an executable launcher (replacement for java.exe) and context switching is expensive.

@dorkbox dorkbox reopened this Aug 14, 2016
@alt-grr
Copy link
Author

alt-grr commented Aug 14, 2016

Ok. I plan to create example test project using TestFX to catch that type of problems earlier in the future.

@dorkbox
Copy link
Owner

dorkbox commented Aug 14, 2016

Good idea.

@dorkbox
Copy link
Owner

dorkbox commented Aug 14, 2016

I should probably list a compatibility matrix that this has been tested on.

@alt-grr
Copy link
Author

alt-grr commented Aug 14, 2016

Minimal not working example:

https://github.com/kuc/SystemTray-JavaFXTest

@dorkbox
Copy link
Owner

dorkbox commented Sep 7, 2016

Just ran some tests in a VM -- it looks like the "normal" (non javaFX) version is working, and I verified that the javaFX version is not.

@dorkbox
Copy link
Owner

dorkbox commented Sep 21, 2016

Got it working in Gnome 3.20+ (but not if gnome-shell is installed on-top of Unity... that just doesn't work at all, but UbuntuGnome works just fine).

@dorkbox
Copy link
Owner

dorkbox commented Sep 21, 2016

Still problems with JavaFX (GTK2) on Ubuntu 16.04 (GTK3) -- working those kinks out...

@dorkbox
Copy link
Owner

dorkbox commented Sep 22, 2016

So it looks like GTK2 on Ubuntu 16.04 is broken in some weird way. GTK2 on xubuntu 16.04 works just fine, GTK3 on Ubuntu/Xubunutu 16.04 works fine -- just GTK2 has issues. This would be why javaFX doesn't work correctly (it uses GTK2).

Edit: Cannonical removed the "application status" indicator panel, so the fallback GtkStatusIcon does not work. Since JavaFX only works with GTK2 (Java9 provides GTK3 bindings), and Cannonical removed GTK2 AppIndicator support, libappindicator1 is the only solution for JavaFX compatibility for Java < 9.

@dorkbox
Copy link
Owner

dorkbox commented Sep 23, 2016

Master branch has the latest -- i haven't pushed a build yet, but I think it's ready, and it will likely be tomorrow that I push the build.

@dorkbox
Copy link
Owner

dorkbox commented Sep 25, 2016

There were some scaling issues with the tray/menu icons. Those issues are getting fixed, and it shouldn't be much longer before I'll have something for testing (it will be downloadable "all-in-one-jars" from my server). If those pass, then I'll push a release.

@dorkbox
Copy link
Owner

dorkbox commented Sep 26, 2016

3.0 beta is released as a "all-in-one" jar, for a variety of different tray types and configurations. I'm starting a new issue to track the progress for this. I definitely will need help testing in different Linux/Mac/Windows configurations (ie: I have no idea if this works in Windows 10, or the latest MacOsX)

I'm closing this issue and tracking everything in a new one. Please use Issue #22 for all related feedback, problems, etc.

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

2 participants