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.


    WebView.eval_js behaves weirdly

    Pythonista
    ui.webview bug pythonista 3
    2
    4
    4633
    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.
    • 0x77
      0x77 last edited by 0x77

      I have some code that runs something like this:

      call = '({})({})'.format(code, args)
      result = js.eval_js(call)
      
      print(result)
      return result
      

      That return value then is sent as a response to an AJAX call from JavaScript to a Bottle server (which made the previous code run).
      If I don't run eval_js and set result to anything - for example: result = 'hello' - the response is sent correctly, but if I use eval_js, firstly it freezes Pythonista for a few seconds, then it prints the correct result (from the eval_jscall), but the response is empty.

      I guess the UI is breaking the connection, somehow, corrupting the response.

      1 Reply Last reply Reply Quote 0
      • ccc
        ccc last edited by

        Can you please provide a minimal script that we can run to show this effect on our own devices?

        1 Reply Last reply Reply Quote 0
        • 0x77
          0x77 last edited by

          I think I found the issue: I was trying to call eval_js while the AJAX request was running (synchronous request, async: false). Python was waiting for the AJAX request to timeout before running js_eval.

          1 Reply Last reply Reply Quote 0
          • ccc
            ccc last edited by

            @0x77 I do not know if it helped this time but I often find that creating that minimal script removes all the cruft and allows you to see where the problem(s) lie. Sherlock Holmes once said something similar.

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