Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Wkwebview crashes at start in beta 340007
-
@mikael WKebView.py crashes at start with _objc_exception.txt containing
The app was terminated due to an Objective-C exception. Details below: 2023-03-14 15:32:08.098719 Completion handler passed to -[CustomNavigationDelegate webView:decidePolicyForNavigationAction:decisionHandler:] was not called
Edit: issue opened in GitHub
-
@cvp I found a work around for this that seems to work for me.
- Run this script once after a cold start of Pythonista.
#coding: utf-8 import sys from objc_util import * class MyWebView(): WKWebView = ObjCClass('WKWebView') def __init__(self): self.create_webview() @on_main_thread def create_webview(self): self.webview = MyWebView.WKWebView.alloc().\ initWithFrame_( ((0,0), (100, 100))).autorelease() if __name__ == '__main__': v = MyWebView() print(v) print('ok')
- Remove the @on_main_thread decorators from 2 eval_js functions.
#@on_main_thread def _eval_js_sync_callback(self, value): self.eval_js_queue.put(value) #@on_main_thread def eval_js_async(self, js, callback=None):
It seems like it's a timing issue.
-
@bosco I have tested with your modification, but not with your script, with the WkWebView.py it-self and it still crashes but without writing anything in _objc_exception.txt. Then, I have restarted Pythonista and reset old code and retried. Also crash without writing in _objc_exception.txt.
Weird, isn'iit? I did not try your code yet.Edit: I have tried your little script with original WkWebView, thus with main_thread, without crash.
-
@cvp I'm running beta 340007 on my iPhone 12 mini, but I haven't upgraded my iPad. In the past, my iPhone has been more likely to crash with code that runs fines on my iPad.
-
-
@cvp Thanks for ALL your help on this forum!
-
@bosco you are too kind