Community
Participate
Working Groups
I have a native window embedded into a Composite created with an EMBEDDED flag. This composite listens for custom events in the non-UI thread from the native window. In one of the handlers I am trying to create a context menu and display it. ``` public void onShowContextMenu() { ....................... widget.getDisplay().syncExec(new Runnable() { public void run() { menu = new Menu(widget.getShell()); MenuItem item1 = new MenuItem(popupMenu, SWT.NONE); item1.setText("Item 1"); MenuItem item2 = new MenuItem(popupMenu, SWT.NONE); item2.setText("Item 2"); menu.setLocation(250, 150); menu.setVisible(true); } }); ................ } ``` The context menu is never displayed in this case. Nevertheless, if I invoke the ```menu.setVisible(true);``` code in one of a selection listener bound to a button on a shell and press this button after the onShowContextMenu() is invoked, the context menu is displayed.
Do you have a standalone snippet that reproduces the issue?
Unfortunately, it's very hard to provide you with a workable standalone snippet as it would contain a private source code. Our SWT widget is a simple composite I am trying to embed into SWT application. A composite contains nothing. All it does is invoking a JNI function and passing its handle to a native application. The native application accepts the handle and embeds a native window into the window with the handle passed. On specific circumstances, the native application invokes a Java callback code through an IPC approach. I expect, that it is possible to create an SWT popup menu from this code via the syncExec or asyncExec method. Hope this additional info sheds a light on the case.
Please note, that this behavior is reproducible in both SWT 3.8.2 and 4.8. When I am trying the SWT 4.8, I can see the following error message in the console: (SWT:18464): GLib-GObject-CRITICAL **: g_object_set_data: assertion 'G_IS_OBJECT (object)' failed
Is this still an issue on SWT master as of today?
It is reproducible with SWT 4.8. Let me check with the latest available SWT release.
The same result with the swt-I20180722-2000-gtk-linux-x86_64 build. The context menu is not displayed and the following error message in the console. (SWT:19336): GLib-GObject-CRITICAL **: g_object_set_data: assertion 'G_IS_OBJECT (object)' failed. This issue is reproducible on Linux only and after I click the embedded into a Composite native window and natively handle this click.
Does the issue occur in both GTK2 and GTK3? Is it possible to provide the steps to reproduce the problem?
The issue is reproducible both with GTK2 and 3. (I suppose I checked it correctly setting the SWT_GTK3 environment variable to "0" in my Idea project). At the moment I do not have specific steps and code sample that can be used to reproduce this issue. I am trying to implement such a sample but it can take some time if it is possible at all.
Created attachment 275103 [details] JNI cpp file
Created attachment 275104 [details] JNI header file
Created attachment 275105 [details] Sample SWT application
Created attachment 275106 [details] Compiled JNI library
Please take a look at the sample application. To reproduce the issue, you need to run the HelloWorld.java file and, before the callback method will be invoked by JNI library, resize the application window.
Hi Nikita, Sorry, if I ask, but I am having some trouble running the snippet. I am able to see shell and the "Show popup manually" button, but I seem to get an UnsatisfiedLinkError exception whenever it invokes the callback method. Exception in thread "Thread-0" java.lang.UnsatisfiedLinkError: org.eclipse.swt.tests.gtk.snippets.HelloWorld.sayHello(JJ)V at org.eclipse.swt.tests.gtk.snippets.HelloWorld.sayHello(Native Method) at org.eclipse.swt.tests.gtk.snippets.HelloWorld.lambda$0(HelloWorld.java:68) at java.lang.Thread.run(Thread.java:748) I tried recompiling the library using g++ -O -Wall -fPIC -DSWT_VERSION=4913 -DLINUX -DGTK -I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.172-9.b11.fc28.x86_64//include -I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.172-9.b11.fc28.x86_64//include/linux -DJNI64 `pkg-config --cflags gtk+-3.0 gtk+-unix-print-3.0` -c HelloWorld.cpp g++ -shared -fPIC -s -o libhelloworld.so HelloWorld.o
(In reply to Xi Yan from comment #14) > Hi Nikita, > > Sorry, if I ask, but I am having some trouble running the snippet. I am able > to see shell and the "Show popup manually" button, but I seem to get an > UnsatisfiedLinkError exception whenever it invokes the callback method. > > Exception in thread "Thread-0" java.lang.UnsatisfiedLinkError: > org.eclipse.swt.tests.gtk.snippets.HelloWorld.sayHello(JJ)V > at org.eclipse.swt.tests.gtk.snippets.HelloWorld.sayHello(Native Method) > at > org.eclipse.swt.tests.gtk.snippets.HelloWorld.lambda$0(HelloWorld.java:68) > at java.lang.Thread.run(Thread.java:748) > > > I tried recompiling the library using > > g++ -O -Wall -fPIC -DSWT_VERSION=4913 -DLINUX -DGTK > -I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.172-9.b11.fc28.x86_64//include > -I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.172-9.b11.fc28.x86_64//include/linux > -DJNI64 `pkg-config --cflags gtk+-3.0 gtk+-unix-print-3.0` -c HelloWorld.cpp > > g++ -shared -fPIC -s -o libhelloworld.so HelloWorld.o Hi Xi, I use the CMake 3.2.2 tool to compile the JNI library. Please find the whole set of source files in the GZ attachment. To build the lib, please run the ./compileLib command from the root folder. Also, please do not forget to add the dependency on the libhelloworld.so file in the Java project.
Created attachment 275187 [details] The sample application sources
Also, please note that I am compiling and running the snippet using the Oracle JDK 1.8. Perhaps, it matters which JDK to use with the already built JNI SO-file.
Hi, Do you have any updates regarding this issue? Perhaps, I can provide you with some additional information?
(In reply to Nikita Shvinagir from comment #18) > Hi, > > Do you have any updates regarding this issue? > Perhaps, I can provide you with some additional information? Thanks for the sources, I have been able to run the snippet. However, I can't seem to reproduce the issue. The context menu pops up by the mouse pointer when the callback is invoked, and the following gets printed to the console. Hello World from C++! handle = 44040218 windowHandle = 62914692 result = 1 In C++, about to enter Java HelloWorld.callback Thread.currentThread().getName() = Thread-0
Created attachment 275256 [details] Behaviour of sample This is the behaviour that I am getting when the callback gets invoked.
Created attachment 275275 [details] Desktop video
(In reply to Xi Yan from comment #20) > Created attachment 275256 [details] > Behaviour of sample > > This is the behavior that I am getting when the callback gets invoked. Yes, sometimes I observe the same behavior as in your video. Could you please try resizing it dragging the bottom-left or top-left window corner? Please do that several times as well. I also attach the desktop video displaying the issue in my local environment. P.S. Please note, that my local Ubuntu environment runs under the Virtual Box virtual machine. Perhaps, this matters.
(In reply to Nikita Shvinagir from comment #22) > Could you please try resizing it dragging the bottom-left or top-left window > corner? > Please do that several times as well. > I also attach the desktop video displaying the issue in my local environment. Hi, I cannot reproduce it on Fedora 28, it seems to work every time.
Which architecture are you running the Fedora on? Linux (x86/GTK+), Linux (x86_64/GTK+), Linux (PPC64/GTK+) or Linux (PPC64LE/GTK+)
(In reply to Xi Yan from comment #23) > (In reply to Nikita Shvinagir from comment #22) > > > Could you please try resizing it dragging the bottom-left or top-left window > > corner? > > Please do that several times as well. > > I also attach the desktop video displaying the issue in my local environment. > > Hi, I cannot reproduce it on Fedora 28, it seems to work every time. Which architecture are you running the Fedora on? Linux (x86/GTK+), Linux (x86_64/GTK+), Linux (PPC64/GTK+) or Linux (PPC64LE/GTK+) Also, please let me know the SWT version you are testing this sample on.
(In reply to Nikita Shvinagir from comment #25) > (In reply to Xi Yan from comment #23) > > (In reply to Nikita Shvinagir from comment #22) > > > > > Could you please try resizing it dragging the bottom-left or top-left window > > > corner? > > > Please do that several times as well. > > > I also attach the desktop video displaying the issue in my local environment. > > > > Hi, I cannot reproduce it on Fedora 28, it seems to work every time. > > Which architecture are you running the Fedora on? Linux (x86/GTK+), Linux > (x86_64/GTK+), Linux (PPC64/GTK+) or Linux (PPC64LE/GTK+) > > Also, please let me know the SWT version you are testing this sample on. I am running under x86_64 GNU/Linux, GTK3.22, and using SWT master as of today.
(In reply to Xi Yan from comment #26) > (In reply to Nikita Shvinagir from comment #25) > > (In reply to Xi Yan from comment #23) > > > (In reply to Nikita Shvinagir from comment #22) > > > > > > > Could you please try resizing it dragging the bottom-left or top-left window > > > > corner? > > > > Please do that several times as well. > > > > I also attach the desktop video displaying the issue in my local environment. > > > > > > Hi, I cannot reproduce it on Fedora 28, it seems to work every time. > > > > Which architecture are you running the Fedora on? Linux (x86/GTK+), Linux > > (x86_64/GTK+), Linux (PPC64/GTK+) or Linux (PPC64LE/GTK+) > > > > Also, please let me know the SWT version you are testing this sample on. > > I am running under x86_64 GNU/Linux, GTK3.22, and using SWT master as of > today. Could you please check this behavior un an Ubuntu 16.04 environment? I am setting up at the moment a Fedora environment to check whether it is not reproducible in my local Fedora environment as well.
(In reply to Nikita Shvinagir from comment #27) > (In reply to Xi Yan from comment #26) > > (In reply to Nikita Shvinagir from comment #25) > > > (In reply to Xi Yan from comment #23) > > > > (In reply to Nikita Shvinagir from comment #22) > > > > > > > > > Could you please try resizing it dragging the bottom-left or top-left window > > > > > corner? > > > > > Please do that several times as well. > > > > > I also attach the desktop video displaying the issue in my local environment. > > > > > > > > Hi, I cannot reproduce it on Fedora 28, it seems to work every time. > > > > > > Which architecture are you running the Fedora on? Linux (x86/GTK+), Linux > > > (x86_64/GTK+), Linux (PPC64/GTK+) or Linux (PPC64LE/GTK+) > > > > > > Also, please let me know the SWT version you are testing this sample on. > > > > I am running under x86_64 GNU/Linux, GTK3.22, and using SWT master as of > > today. > > Could you please check this behavior un an Ubuntu 16.04 environment? > I am setting up at the moment a Fedora environment to check whether it is > not reproducible in my local Fedora environment as well. Actually can you rerproduce on Ubuntu 18.04? If not it's probably some issue with older GTK versions. Also what happened with your Fedora test?
Any progress with testing here?
Closing this ticket now as there has been no response in awhile. Please reopen it if you can reproduce the issue on GTK3.22/24 using SWT 4.10.