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

Error after closing a tab in fullscreen mode while multiple tabs opened MacOS. #1236

Closed
Igazii opened this issue Oct 15, 2023 · 1 comment
Closed

Comments

@Igazii
Copy link

Igazii commented Oct 15, 2023

Specification

  • pywebview version: 4.3.3
  • operating system: MacOS Ventura 13.4.1
  • web renderer: Webkit
  • python 3.9

Description

When i open multiple tabs like in this example:

import webview
import sys


if __name__ == '__main__':
    window = webview.create_window(
        "Test"
    )

    webview.create_window("Test 2")
    webview.start(debug=True)
    sys.exit()

I set one of the tabs in full screen mode, and after closing it - the rest of the tabs being closed too and I see the following traceback in the terminal and an error thrown by the system(see the screenshot):

Screenshot 2023-10-15 at 23 01 51

Python[70795:6186822] *** Terminating app due to uncaught exception 'OC_PythonException', reason: '<class 'AttributeError'>: 'NoneType' object has no attribute 'window''
*** First throw call stack:
(
0 CoreFoundation 0x000000019cacf154 __exceptionPreprocess + 176
1 libobjc.A.dylib 0x000000019c5ee4d4 objc_exception_throw + 60
2 CoreFoundation 0x000000019caf83a0 _CFBundleGetValueForInfoKey + 0
3 _objc.cpython-39-darwin.so 0x00000001060eb9b8 PyObjCErr_ToObjCWithGILState + 52
4 _objc.cpython-39-darwin.so 0x00000001060cedd0 method_stub + 5852
5 libffi.dylib 0x00000001ac868f44 ffi_closure_SYSV_inner + 816
6 libffi.dylib 0x00000001ac8601e8 ffi_closure_SYSV + 56
7 CoreFoundation 0x000000019ca4b180 CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER + 148
8 CoreFoundation 0x000000019cae6eec ___CFXRegistrationPost_block_invoke + 88
9 CoreFoundation 0x000000019cae6e34 _CFXRegistrationPost + 440
10 CoreFoundation 0x000000019ca1c4cc _CFXNotificationPost + 704
11 Foundation 0x000000019d97a8f4 -[NSNotificationCenter postNotificationName:object:userInfo:] + 88
12 AppKit 0x000000019fcbae1c -[NSWindow _setFrameCommon:display:fromServer:] + 2692
13 AppKit 0x00000001a04e9fd4 -[_NSExitFullScreenTransitionController setupWindowForAfterFullScreenExit] + 460
14 AppKit 0x00000001a04ece0c __46-[_NSExitFullScreenTransitionController start]_block_invoke.45 + 52
15 libdispatch.dylib 0x000000019c7c6874 _dispatch_call_block_and_release + 32
16 libdispatch.dylib 0x000000019c7c8400 _dispatch_client_callout + 20
17 libdispatch.dylib 0x000000019c7d6bf8 _dispatch_main_queue_drain + 928
18 libdispatch.dylib 0x000000019c7d6848 _dispatch_main_queue_callback_4CF + 44
19 CoreFoundation 0x000000019ca97c54 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 16
20 CoreFoundation 0x000000019ca553d4 __CFRunLoopRun + 1992
21 CoreFoundation 0x000000019ca544b8 CFRunLoopRunSpecific + 612
22 HIToolbox 0x00000001a629ec40 RunCurrentEventLoopInMode + 292
23 HIToolbox 0x00000001a629ea7c ReceiveNextEventCommon + 648
24 HIToolbox 0x00000001a629e7d4 _BlockUntilNextEventMatchingListInModeWithFilter + 76
25 AppKit 0x000000019fc75d44 _DPSNextEvent + 636
26 AppKit 0x000000019fc74ee0 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 716
27 AppKit 0x000000019fc69344 -[NSApplication run] + 464
28 libffi.dylib 0x00000001ac860050 ffi_call_SYSV + 80
29 libffi.dylib 0x00000001ac868af8 ffi_call_int + 1208
30 _objc.cpython-39-darwin.so 0x00000001060f1c88 objcsel_vectorcall_simple + 1116
31 Python 0x000000010545a93c call_function + 416
32 Python 0x0000000105457fdc _PyEval_EvalFrameDefault + 23108
33 Python 0x0000000105384cec function_code_fastcall + 112
34 Python 0x000000010545a93c call_function + 416
35 Python 0x0000000105457fb8 _PyEval_EvalFrameDefault + 23072
36 Python 0x000000010545b864 _PyEval_EvalCode + 2988
37 Python 0x0000000105384c70 _PyFunction_Vectorcall + 256
38 Python 0x000000010545a93c call_function + 416
39 Python 0x0000000105458058 _PyEval_EvalFrameDefault + 23232
40 Python 0x000000010545b864 _PyEval_EvalCode + 2988
41 Python 0x0000000105384c70 _PyFunction_Vectorcall + 256
42 Python 0x000000010545a93c call_function + 416
43 Python 0x0000000105457fdc _PyEval_EvalFrameDefault + 23108
44 Python 0x000000010545b864 _PyEval_EvalCode + 2988
45 Python 0x0000000105384c70 _PyFunction_Vectorcall + 256
46 Python 0x000000010545a93c call_function + 416
47 Python 0x00000001054580d4 _PyEval_EvalFrameDefault + 23356
48 Python 0x000000010545b864 _PyEval_EvalCode + 2988
49 Python 0x00000001054524d0 PyEval_EvalCode + 80
50 Python 0x000000010549a368 pyrun_file + 304
51 Python 0x000000010549833c PyRun_SimpleFileExFlags + 624
52 Python 0x00000001054b5664 Py_RunMain + 1700
53 Python 0x00000001054b5b28 pymain_main + 340
54 Python 0x00000001054b5ba4 Py_BytesMain + 40
55 dyld 0x000000019c61ff28 start + 2236
)
libc++abi: terminating due to uncaught exception of type NSException

I tried to solve it myself and noticed an interesting thing. If I clear all the tabs inside the windowWillClose_ hook, everything works fine. I did something like this:

  for i in list(BrowserView.instances.values()):
      if getattr(i, 'window'):
          del BrowserView.instances[i.uid]

          if i.pywebview_window in windows:
              windows.remove(i.pywebview_window)

I thought that I would be able to put it inside applicationShouldTerminate_, but it seems like this hook doesn't work. I have also tried to implement applicationWillTerminate_, but it doesn't work either.

I think that the problem could be related with SuddenTermination and I've tried to turn it off using this https://developer.apple.com/documentation/foundation/processinfo/1412841-disablesuddentermination, but it ended up with no success. Still working on this issue. Maybe you have some ideas/suggestions on this matter? I want to fix it myself and make a contribution, if it's possible, thank you.

Practicalities

  • YES I am willing to work on this issue myself.

  • NO I am prepared to support this issue financially.

@Igazii Igazii changed the title Error after closing a tab in fullscreen mode while multiple tabs were opened MacOS. Error after closing a tab in fullscreen mode while multiple tabs opened MacOS. Oct 15, 2023
@r0x0r
Copy link
Owner

r0x0r commented Oct 16, 2023

The problem was with windowDidResize_, windowDidExitFullScreen_ etc event handlers. Those were triggered after window was already destroyed. Fixed by checking whether BrowserView instance exists in each event handler. The fix can be found in the master branch.

@r0x0r r0x0r closed this as completed Oct 16, 2023
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