6 Replies
      Latest reply on Aug 30, 2018 4:32 AM by lailton
      lailton Level 1 Level 1 (0 points)

        Hi everyone,

         

        I have a complete application created with HTML5+JS and I use "Bridge commands" to call some C functions.

        Everything works fine.

         

        But I have a stupid problem sometimes when the device is locked and the application still for a long time in background on the moment that I unlock the device it returns to the application as expected but the events ( javascript ) not respond anymore.

         

        So I need to finish the application and start again from the scratch and everything starts to work again.

         

        Temporary I made a procedure to check the state and when I unlock the device, I force the page to reload.

        It works, but if possible I would like to use another way.


        Someone has the same issue? some tips?

         

        Thanks

        • Re: UIWebView - Javascript stop to respond
          KMT Level 9 Level 9 (15,255 points)

          Is there a reason you're not using WKWebView instead of the long since deprecated uiwebview? We've been waiting for UIWebView to be officially deprecated since iOS 8."

          • Re: UIWebView - Javascript stop to respond
            eskimo Apple Staff Apple Staff (12,455 points)

            KMT wrote:

            Is there a reason you're not using WKWebView instead of the long since deprecated UIWebView?

            Hmmm, UIWebView is only officially deprecated in the iOS 10.12 beta SDK, which hasn’t yet shipped, so labelling it as “long since deprecated” seems a bit rough.


            lailton wrote:

            I have a complete application created with HTML5+JS and I use "Bridge commands" to call some C functions.  …

            But I have a stupid problem sometimes when the device is locked and the application still for a long time in background on the moment that I unlock the device it returns to the application as expected but the events ( javascript) not respond anymore.

            I’m not familiar with these “Bridge commands” but I suspect they’re using some sort of communication channel that gets broken when you move into the background.  A classic example of this would be a TCP connection, where socket resource reclaim can tear the connection if you get suspended (see Technote 2277 Networking and Multitasking).

            Your best option here is, as KMT suggested, to move on to WKWebView.  It has much nicer native integration features, including WKScriptMessage, a very nice mechanism to message native code from JavaScript.

            Oh, and it’s not deprecated (-:

            Share and Enjoy

            Quinn “The Eskimo!”
            Apple Developer Relations, Developer Technical Support, Core OS/Hardware
            let myEmail = "eskimo" + "1" + "@apple.com"