Bug 577515 - [Wayland] Ubuntu 21.10 Window size is not correct + Gtk-CRITICAL assertion 'GTK_IS_WIDGET (widget)' failed
Summary: [Wayland] Ubuntu 21.10 Window size is not correct + Gtk-CRITICAL assertion 'G...
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.18   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2021-11-29 04:30 EST by X L CLA
Modified: 2023-06-29 04:38 EDT (History)
2 users (show)

See Also:


Attachments
Window size isn't correct (31.98 KB, image/jpeg)
2021-11-29 04:30 EST, X L CLA
no flags Details
Sample code (1.31 KB, text/x-java)
2021-11-29 05:02 EST, X L CLA
no flags Details
Ubuntu 21.10 sample code run screen snapshot (41.01 KB, image/jpeg)
2021-11-29 05:04 EST, X L CLA
no flags Details
Sample code update 2023 (1.62 KB, text/x-java)
2023-06-27 00:01 EDT, X L CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description X L CLA 2021-11-29 04:30:45 EST
Created attachment 287587 [details]
Window size isn't correct

Hi all, I created a Shell, and populate its content, open the window.

But I got the following error cause my App size isn't correct.
(It seems that the assertion aborted following-up code execution, so the size remains the default.

```
(JavaEmbeddedFrame:7354): Gtk-CRITICAL **: 14:12:26.084: gtk_widget_get_scale_factor: assertion 'GTK_IS_WIDGET (widget)' failed

```

OS: Linux Ubuntu 20.10 x86_64

FYI, as I tested, in Ubuntu 20.04, the same code, has no such assertion error and the window size is correct.
Comment 1 Andrey Loskutov CLA 2021-11-29 04:32:43 EST
Please provide version of gtk3 library on Ubuntu 21.10 & simple snippet to reproduce.
Comment 2 Andrey Loskutov CLA 2021-11-29 04:33:23 EST
Also please try with latest SWT available (looks like you are on 4.18).
Comment 3 X L CLA 2021-11-29 04:35:45 EST
Correction:
OS: Linux Ubuntu 21.10 x86_64

GTK version:

$ dpkg -l libgtk2.0-0 libgtk-3-0 | grep libgtk
ii  libgtk-3-0:amd64  3.24.30-1ubuntu1 amd64        GTK graphical user interface library
ii  libgtk2.0-0:amd64 2.24.33-2ubuntu1 amd64        GTK graphical user interface library - old version
Comment 4 X L CLA 2021-11-29 05:02:46 EST
Created attachment 287588 [details]
Sample code
Comment 5 X L CLA 2021-11-29 05:04:11 EST
Created attachment 287589 [details]
Ubuntu 21.10 sample code run screen snapshot
Comment 6 X L CLA 2021-11-29 05:04:43 EST
@Andrey Loskutov

Sample code are included in **Attachments**
Comment 7 X L CLA 2021-11-29 05:05:49 EST
Run with Ubuntu 21.10 and SWT I20211128-1800 (Latest build)
Comment 8 Andrey Loskutov CLA 2021-11-29 05:44:58 EST
(In reply to X L from comment #4)
> Created attachment 287588 [details]
> Sample code

Works fine for me on RHEL 7.9 / GTK 3.22 / SWT master, however I use X11 and I don't run on HiDPI screen (which you seem to use).

Could you please try on X11 & on non-HiDPI screen?

Could be either GTK 3.24.30 or Wayland or HiDPI support issue.
Comment 9 X L CLA 2021-11-29 06:16:09 EST
My config is Ubuntu 21.10(GNOME) and a 4k screen(100% and 200% scaling) can produce this bug
Comment 10 X L CLA 2021-11-29 06:38:27 EST
> Could be either GTK 3.24.30 or Wayland or HiDPI support issue.


Is there any workaround I can do to solve this bug?
(We have a massive quantity of users which run those code)
Comment 11 Andrey Loskutov CLA 2021-11-29 07:34:22 EST
(In reply to X L from comment #10)
> > Could be either GTK 3.24.30 or Wayland or HiDPI support issue.
> 
> 
> Is there any workaround I can do to solve this bug?
> (We have a massive quantity of users which run those code)

No idea. Are you using Wayland or X11? May be switching to another would help? 

I assume you have evaluated Ubuntu 21.10 before moving to it? Now it is most likely too late for workarounds, and downgrading to older GTK version will be not possible I guess :-(

Unfortunately I don't have yet environment with 3.24.30 GTK3 to play with.
Comment 12 Joel Majano CLA 2021-11-29 10:20:31 EST
I tried a few configurations on my Fedora 35 GTK 3.24.30 environment. At 4k 200% I don't get any errors running with GDK_BACKEND=x11 or with Wayland. At non-hi dpi resolutions I don't get any critical/warning logs either.

However, I do notice that in Wayland, the window size is completely incorrect, as in, much smaller than specified within the code provided. Using GDK_BACKEND=x11, the window is the correct.

@X L: Is it possible for you to press CTRL-SHIFT-I then under the "General" tab then let us know what GDK Backend you're running on?
Comment 13 X L CLA 2021-11-29 20:35:23 EST
Thank you all!

I've checked, the default WM is Wayland in Ubuntu 21.10, I didn't change anything, just stick with the default config.

```
$ env | grep ^XDG_
XDG_CURRENT_DESKTOP=ubuntu:GNOME
XDG_MENU_PREFIX=gnome-
XDG_SESSION_DESKTOP=ubuntu
XDG_RUNTIME_DIR=/run/user/1000
XDG_SESSION_TYPE=wayland
XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
XDG_SESSION_CLASS=user
```

And switch to X11 can solve my problem `GDK_BACKEND=x11 java -cp .:./swt.jar Main`

> and downgrading to older GTK version will be not possible I guess :-(

Impractical I'm afraid since it's bundled with Ubuntu 21.10 by default, end-user have no such experience to do such heavy work though.
Comment 14 X L CLA 2023-06-27 00:01:38 EDT
Created attachment 289114 [details]
Sample code update 2023
Comment 15 Alexander Kurtakov CLA 2023-06-27 05:10:23 EDT
SWT project switched to using Github https://github.com/eclipse-platform/eclipse.platform.swt and almost no one looks at bugzilla anymore. 
Please consider providing your snippet as a JUnit test via a PR that might even lead to a fix for the issue.
Comment 16 X L CLA 2023-06-29 04:38:27 EDT
FYI, I can fix this bug (as a workaround) by adding the `SWT.RESIZE` to the window style, and the window will appear as its `setSize(x, y)` size.