New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question about javascript bridge differences on osx and ios #199
Comments
The bridge is based on unity-webview/sample/Assets/Scripts/SampleWebView.cs Lines 50 to 73 in 97293c8
Especially the After the Objective-C code receiving a message from JavaScript, however, it utilizes https://forum.unity3d.com/threads/monopinvokecallback-in-unity.132510/ |
Thank you very much for the information about what might cause delays. I tried the wkwebview version also and it had the same issues. I will do some experiments with location vs iframe and UnitySendMessage vs MonoPInvokeCallback. |
I built a test project to see the problems more clearly. It fires off calls to javascript functions that call unity back during FixedUpdate, Update, and LateUpdate and documents when they return. I tried getting rid of the iframe methods, and also using setTimeouts to delay the iframes. I also did some more experiments with wkwebview. In the experiments the return calls from javascript always seem to happen after LateUpdate no matter when they are called. Also they return at random times after LateUpdate. According to documentation on UnitySendMessage it has a one frame delay so this may be the problem. I also downloaded a few more projects for unity including |
I've implemented |
Great. I'll run some experiments and get back to you. |
Success! There are now no frame delays. I am sending EvaluateJS with return calls consecutively in FixedUpdate, Update, and LateUpdate. The returns are immediate and everything stays in sync. |
I'm sending some information back and forth using the javascript bridge. On osx the information is sent back and forth immediately. For example if I send a command to javascript and a return command during FixedUpdate it is sent back before FixedUpdate finishes. Same with Update and Late Update.
On IOS if I send a command to javascript during FixedUpdate it doesn't return until fixed,update,late have occured, or a frame later.
Why is there a difference? It doesn't seem related to the framerate.
Is there any way to get the javascript bridge to return immediately on ios rather than a frame later?
The text was updated successfully, but these errors were encountered: