Welcome Guest Search | Active Topics | Sign In | Register

order of execution for multiple calls to WebView.QueueScriptCall Options
Paul Joyce
Posted: Tuesday, March 19, 2019 12:08:03 AM
Rank: Newbie
Groups: Member

Joined: 1/21/2015
Posts: 4
Hi,
We have recently upgraded from EO circa 2015 to EO.2019.

A problem we are facing is that when we call QueryScriptCall a few times in succession, the results are not what we expect. Eg:

Code: C#
myWebView.QueueScriptCall("startApp()");
// some .NET stuff
myWebView.QueueScriptCall("startAppSecondPart()");
myWebView.QueueScriptCall("initializePlugin()");


Using the new version, we get JavaScript errors in the initializePlugin() that indicate startApp() has not finished yet, or perhaps not run. If we change all these calls to EvalScript, things initialize as expected, but we get other problems later with re-entrant code (.NET->JS->.NET->JS etc)

Questions:
1. Should we expect that script calls queued will be processed in the order they are queued?
2. Can we assume only one script will be called at once?

Thanks, Paul
eo_support
Posted: Tuesday, March 19, 2019 10:34:26 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,067
Hi,

QueueScriptCall does guarantee they code will be called in the same order they are received and all the script will be called by the same thread one after another. What you are running into might be a callback issue. For example, if startApp schedule some callback (which can be triggered by various means such as certain DOM event, timer, etc) and returns immediately, then by the time startAppSecondPart is called, that callback may have not been called yet, which would cause the false impression that startApp has not been called. Another possibility might be startApp was called too early and it throws an exception thus failed to initialize certain parts. So you may want to debug your JavaScript code to find out exactly what happened. You can use built-in debug feature to debug your page:

https://www.essentialobjects.com/doc/webbrowser/advanced/debug.aspx

Thanks!
Paul Joyce
Posted: Thursday, March 21, 2019 5:26:26 PM
Rank: Newbie
Groups: Member

Joined: 1/21/2015
Posts: 4
Thanks for your suggestions. What seems to have been the problem was that as soon as callbacks are encountered, a queued script is executed in preference to the callback. This might be different to older versions.
I solved it by creating my own queue, and trickle-feeding the JavaScript in, waiting for ScriptCallDone before calling QueueScriptCall again.
eo_support
Posted: Saturday, March 23, 2019 2:33:06 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,067
That makes sense. Glad to hear that you got it working.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.