Open gitillusion09 opened 1 month ago
Do you happen to have a standalone example that would reproduce the bug?
Yes, here you go: https://github.com/gitillusion09/pywebview-test
It is a basic (very basic) example but you got the idea. I took as reference your Serverless example, and tweaked it a bit to reproduce the bug: just launch it, the thread will start printing current date on the UI. When closing the app (with the window's cross), the app hangs on forever, even though I terminate the thread from the on_closing() method.
Thanks a lot for your time
@r0x0r It seems to me that the following line should_cancel = self.closing.set()
in the on_closing()
method is what is blocking the app
I modified event handler logic so that instead of launching a thread that is blocked via a semaphore, it executes event handlers synchronously. The fix concerns only the closing event. This fixes the problem in your example. The fix could be found in the master branch.
Another fix would be making your background thread daemon and getting rid of the join.
Thanks a lot for your fix ! Appreciate it :)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hello @r0x0r :) When closing, the app keeps hanging forever. I know there was already a similar issue back in 2017 (https://github.com/r0x0r/pywebview/issues/138), but I think the fix does not work (anymore ?) on Windows 11.
I work with pywebview 5.1. I have a renderer thread that in some cases, calls the evaluate_js method periodically. If the application closes at this exact moment, and even though the thread has been joined, the app keeps hanging forever. Does anyone have the issue on Windows?
I am not sure to have the skills to work on this issue myself...