|
Rank: Advanced Member Groups: Member
Joined: 2/8/2019 Posts: 57
|
We use the WPF EO component as the user interface for a line-of-business application (currently using 21.2.47, as delivered by Nuget).
The application is wrapped in an installer using WiX.
We see that sometimes (but not all the time), after the first install of the application the web page fails to load.
i.e. we do: webControl.WebView.Url = newUrl;
where newUrl is a locally held file ("i.e. file:///C:/Program%20Files/path/to/our/html/file.html").
We then never see any LoadCompleted or LoadFailed event. If we close the app (Alt-F4) and launch it again, it works as expected.
If I install with the Debugger enabled (i.e. ShowDebugUI of true), I can see the WebView instance and within the Chrome Debugger I can see the HTML page has been loaded. No errors are listed in the console.
Doing a window.location.reload or F5 within the debugger seems to cause Chrome to refetch the HTML/CSS/JS, but we still never get a LoadCompleted or LoadFailed event.
Any tips about how to go about debugging this?
What is the internal logic that triggers the LoadCompleted or LoadFailed events?
|
|
Rank: Advanced Member Groups: Member
Joined: 2/8/2019 Posts: 57
|
In addition, we have a registered callback: this.webView.RegisterJSExtensionFunction("WebAppMessage", new JSExtInvokeHandler(this.OnWebAppMessage));
In this state (neither LoadCompleted/LoadFailed have been invoked), we can still pass messages from JS to C# using this (so at some level EO knows the browser is up and running).
Thanks, Joe
|
|
Rank: Advanced Member Groups: Member
Joined: 2/8/2019 Posts: 57
|
Sorry, last post for now.
Looking at document.readyState using the Chrome Debugger console shows "complete"
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi, This must be some kind of timing issue. Is it possible for you to isolate the problem into a test project and then send the test project to us? See here for more details: https://www.essentialobjects.com/forum/test_project.aspxThanks
|
|
Rank: Advanced Member Groups: Member
Joined: 2/8/2019 Posts: 57
|
Thanks, I'll attempt to produce a test case, though this may be tricky.
In the mean time, I've done some more investigation.
We were using the LoadCompleted callback to trigger the application to move to the next stage of initialization (i.e. we wait until the browser has fully finished loading, then we pass it a chunk of "configuration" JSON to finish the process).
I've now amended this, so instead, we invoke some JavaScript when the browser fires windows.OnLoad() (rather than waiting for LoadCompleted). This JavaScript then invokes a function registered with RegisterJSExtensionFunction.
We seem to always get this invocation on the C# side, so I believe the browser always completes loading. In this modified code, we then use QueueScriptCall to pass the "configuration" JSON back to the browser (as we can't EvalScript from within a callback registered with RegisterJSExtensionFunction). However, this QueueScriptCall sometimes fails (or at least, doesn't get invoked).
I'm assuming that whatever is blocking the LoadCompleted from firing is also causing whatever has been queued by QueueScriptCall to not run.
What is the logic behind LoadCompleted (as it seems to be more than just repeating windows.onLoad())? Is there any linkage between LoadCompleted not firing and JavaScript enqueued using QueueScriptCall being blocked?
I'm beginning to wonder if I have a stray call to QueueScriptCall prior to getting the LoadCompleted event. Is it valid to call QueueScriptCall prior to LoadCompleted or could this be causing the issue I'm seeing?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi,
There is no direct relationship between LoadCompleted and window.onload even though they usually occurs together. These two events are reported by different components of the browser engine. LoadCompleted is reported by the loader, where as window.onload is reported by the JavaScript engine. It is possible to have one without the other. For example, window.onload would not be fired if JavaScript is disabled, but LoadCompleted will still be fired in this case.
Likewise, QueueScriptCall should not affect LoadCompleted directly either because QueueScriptCall works with the script engine and LoadCompleted comes from the loader. It can however affect LoadCompleted indirectly. For example, you may run script code to redirect the current Url to a different one before LoadCompleted is fired. In that case you would receive LoadFailed (with "Cancel" error code instead). But in all cases, you should either get a LoadCompleted or a LoadCanceled. According to your description this is not the case, so we will need to reproduce that in order to investigate.
Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 2/8/2019 Posts: 57
|
Thanks for the information :)
I found that, under rare circumstances, we may queue some JavaScript using QueueScriptCalls very early in the loading process (i.e. before LoadCompleted had fired).
Having put protection around this (so we only queue up JavaScript after getting LoadCompleted), we are no longer seeing an issue.
We have logging attached to LoadFailed and were never seeing that get called. It feels like there is some interaction between the Loader and script engine, if we enqueue script calls while the load is in progress.
I'll try and simulate this by performing some QueueScriptCalls while loading is occurring and see if I can get it to reliably fail (i.e. no LoadCompleted or LoadFailed)
|
|
Rank: Advanced Member Groups: Member
Joined: 2/8/2019 Posts: 57
|
More information.
If I queue up some QueueScriptCalls on a timer (every 50ms) then I can get this to occur reliably (about 50% of the time), but ONLY from a full device reboot.
This fault doesn't occur if I then close/restart the application OR sign-out/sign-in/run the application.
So, I'd say I'm fairly certain its timing related, and to do with the reboot.
If I don't do any QueueScriptCalls prior to LoadCompleted, it never fails.
Having got a workaround (by not doing any QueueScriptCalls prior to LoadCompleted), I'm happy that my immediate issue has been resolved, and leave it up to you if you want (or want me) to continue to investigate.
Thanks, Joe
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Thanks for the additional information. What do you do in your QueueScriptCall? Does the problem occurs if you do something "harmless" like QueueScriptCall("var i = 0;")?
|
|
Rank: Advanced Member Groups: Member
Joined: 2/8/2019 Posts: 57
|
I've been doing a "console.log('abc')" every 50ms for testing.
Happy to give something with no side affects a go and report back.
|
|
Rank: Advanced Member Groups: Member
Joined: 2/8/2019 Posts: 57
|
The issue still occurs with QueueScriptCall("var i = 0;").
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Thanks for the additional information!
|
|