pythonista-webview
pythonista-webview copied to clipboard
Wkwebview crashes at start in Pythonista beta 340007
WKWebView.py it-self crashes with this error
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
Something similar? Here
https://github.com/pichillilorenzo/flutter_inappwebview/issues/1221
Thanks for reporting this. Seems something has changed in Apple APIs.
It is unlikely I will look at this soon. PRs are very welcome.
WKWebView does not work with version 3.4 (Release of AppStore that is not TestFlight), is it the same problem?
This issue with my WKWebView wrapper is unlikely to be dependent on Pythonista version.
But the soon-to-be-released version of Pythonista is expected to contain an ”official” (and working) version of WKWebView.
Yes but the Pythonista WkWebView does not support the add_script method
Hmm, it’s like 5 lines of code. Maybe we could see if we could get it added to the core version, or subclass and it ourselves.
Sure!
This modified version is working for me on Pythonista 3.4. https://gist.github.com/sbbosco/1290f59d79c6963e62bb678f0f05b035
Changes are:
def __init__(self,
swipe_navigation=False,
data_detectors=NONE,
log_js_evals=False,
respect_safe_areas=False,
inline_media=None,
airplay_media=True,
pip_media=True,
**kwargs):
dummy = self.dummy_webview()
del dummy
WKWebView.webviews.append(self)
@on_main_thread
def dummy_webview(self):
dummy1 = WKWebView.WKWebView.alloc().initWithFrame_(((0,0), (100, 100))).autorelease()
#@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):
@ui.in_background
def clear_cache(self, completion_handler=None):
#v.clear_cache()