MixinNetwork / MixinNetwork/flutter-plugins
[desktop_webview_window] Closes entire app when webview closes on Linux
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 512
- Forks
- 292
- Avg merge
- 15h 8m
- Merged PRs (30d)
- 7
Description
When closing a webview on linux, it closes the entire app as well.
Reproduce Steps
Steps to reproduce the behavior:
- Open a webview
- Close the webview
- Entire app closes
Expected behavior
The webview should close and the app should stay open
Version (please complete the following information):
- Flutter Version: 3.35.4
- OS: Linux
- plugin: [desktop_webview_window: 0.2.3]
Additional context
I've somewhat tracked down what is causing the issue, but I'm not sure the best approach to fix it.
When the webview window initializes the flutter view it eventually registers this callback to unrealize_cb here which is received when the window closes. I think this is shared with the main flutter application, and causes this error.
(webview_window_example:63441): Gdk-ERROR **: 21:38:39.941: The program 'webview_window_example' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadAccess (attempt to access private resource denied)'.
(Details: serial 12779 error_code 10 request_code 152 (GLX) minor_code 26)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the GDK_SYNCHRONIZE environment
variable to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
Lost connection to device.
Stack trace, showing the issue coming from unrealize_cb
#0 0x00007ffff40ba8d0 in _XError () at /lib/x86_64-linux-gnu/libX11.so.6
#1 0x00007fffdc05fc06 in () at /lib/x86_64-linux-gnu/libGLX_mesa.so.0
#2 0x00007fffdc05fa92 in () at /lib/x86_64-linux-gnu/libGLX_mesa.so.0
#3 0x00007fffe7125492 in () at /lib/x86_64-linux-gnu/libGLX.so.0
#4 0x00007fffe7127813 in () at /lib/x86_64-linux-gnu/libGLX.so.0
#5 0x00007fffe712c277 in () at /lib/x86_64-linux-gnu/libGLX.so.0
#6 0x00007ffff576de7b in () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#7 0x00007ffff5738fd3 in gdk_gl_context_make_current () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#8 0x00007ffff7155057 in unrealize_cb(_FlView*) ()
Just commenting out the lines that setup the flutter view allows the webview to close without taking the rest of the app with it. I haven't been able to find any way to keep it working while also setting up the flutter view
Here is the simple patch im using at the moment to work around the issue
https://github.com/MixinNetwork/flutter-plugins/compare/main...commetchat:mixin-flutter-plugins:webview-patch
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the Linux failure with packages/desktop_webview_window/linux/webview_window.cc, starting at the Flutter view setup around line 131 and the linked Flutter engine fl_view.cc unrealize_cb path. Compare the reported workaround, then verify that closing the webview no longer closes the main app or produces the shown GLX error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, flutter, linux
- Domain
- desktop, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100