omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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

    Pythonista
    2
    7
    79
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • cvp
      cvp last edited by cvp

      @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
      

      Something similar?

      Edit: issue opened in GitHub

      bosco 1 Reply Last reply Reply Quote 0
      • bosco
        bosco @cvp last edited by

        @cvp I found a work around for this that seems to work for me.

        1. 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')
        
        
        1. 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.

        cvp 1 Reply Last reply Reply Quote 0
        • cvp
          cvp @bosco last edited by cvp

          @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.

          bosco 1 Reply Last reply Reply Quote 0
          • bosco
            bosco @cvp last edited by

            @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 1 Reply Last reply Reply Quote 0
            • cvp
              cvp @bosco last edited by

              @bosco I run on iPad Air 5 (M1) with beta 340007. I have opened an issue in Github and @mikael will check it. No urgence, but perhaps he would be interested by your workaround. Wait and see. Thanks for helping.

              bosco 1 Reply Last reply Reply Quote 0
              • bosco
                bosco @cvp last edited by

                @cvp Thanks for ALL your help on this forum!

                cvp 1 Reply Last reply Reply Quote 0
                • cvp
                  cvp @bosco last edited by

                  @bosco you are too kind

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  Powered by NodeBB Forums | Contributors