Logo
My Account |  Site Map | Contact Us  
Welcome Guest Search | Active Topics | Sign In | Register

Channel is Invalid or not Ready exception with EvalScript. Unresponsive with QueueScriptCall Options
mcontreras
Posted: Thursday, June 14, 2018 6:56:47 PM
Rank: Newbie
Groups: Member

Joined: 5/25/2018
Posts: 6
I am attempting to run a piece of JavaScript for a EoWebBrowser control I have loaded on a form, during the form OnShown() method, that is called after I do a Form.ShowDialog(myForm);

Using EvalScript during this event (before or after base.Show runs) I get an exception error:

Exception:
EO.WebBrowser.JSInvokeException: EvalScript failed because script engine is not ready or is shutdown before the script can finish. Please use QueueScriptCall instead of EvalScript to execute JavaScript code in this case.


So I tried using the CanEvalScript property to check if it was safe to run, but it never is set to true at the method, I assume because the Shown is not complete.

Witht that result, I turned to using QueueScriptCall, but I get no effect whatsoever, even after the Show Method executed and exited from. The script is never executed and I dont even get an exception error.


Using a different approach, I called a Refresh() on the Shown event before trying to call EvalScript again. Then I got the following:


EO.WebBrowser.JSInvokeException: EvalScript failed because channel is invalid or not ready.


> Is there a way I can check why "the channel is invalid"? This for the Refresh() case, where I think I have the best possibilities because I have forced the Form to finish loading and show.

> Should I avoid calling EvalScript or QueueScriptCall from the form's OnShown() event? I understand at that point the component is not ready possibly so this might be a limitation.




eo_support
Posted: Friday, June 15, 2018 3:23:02 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 20,466
Hi,

This will occur when you call EvalScript too early before the WebView has been fully created. However QueueScriptCall should work. If you continue to have problems, please try to isolate the problem into a test project and send the test project to us. See here for more details:

https://www.essentialobjects.com/forum/test_project.aspx

Once we have the test project, we will be happy to investigate further.

Thanks!
mcontreras
Posted: Monday, June 25, 2018 2:51:10 PM
Rank: Newbie
Groups: Member

Joined: 5/25/2018
Posts: 6
Test Project has been sent.
eo_support
Posted: Monday, June 25, 2018 5:25:19 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 20,466
Hi,

We have looked into the test project you sent to us. The reason is because you called QueueScriptCall too early before the WebView has been initialized. To correctly handle this situation, it would require code changes both from your side and from our side. We will change our side first and then will reply here again when the new build is ready.

Thanks!
mcontreras
Posted: Monday, June 25, 2018 6:23:48 PM
Rank: Newbie
Groups: Member

Joined: 5/25/2018
Posts: 6
Thank you very much for your reply, I will wait for your side then.

[Edit] Do you have by any chance a schedule for build releases or ETA for your next release?

Regards!
eo_support
Posted: Tuesday, June 26, 2018 9:53:39 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 20,466
It should be out next week.
eo_support
Posted: Friday, July 6, 2018 2:12:23 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 20,466
Hi,

This is just to let you know that we have posted a new build that should resolve this issue. Please download it from our download page and see how it goes.

Thanks!
mcontreras
Posted: Monday, July 9, 2018 11:39:44 AM
Rank: Newbie
Groups: Member

Joined: 5/25/2018
Posts: 6
Good day,

I installed this today and changed the reference to the relevant components but I am seeing the same problem behavior with the test project I emailed (QueueScriptCall not executing the code. EvalScript crashes when used because of the Webview not ready message). You mentioned code changes would be required on both sides, can you give me any additional information on this? Or if I should be monitoring an additional property, etc.

Thanks!
eo_support
Posted: Wednesday, July 11, 2018 5:07:00 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 20,466
Hello,

Sorry we missed the information about the code change on your end. You will need to change the script code to something like the following:

Code: JavaScript
window.onload = function() { your_original_script_code_here };


The reason is because when you call QueueScriptCall before the WebView has been fully initialized, the code will be run as soon as possible, which is too early that document.body is still null. Since in your script code you call document.body.appendChild, this will cause a null reference exception since document.body is still null. Using window.onload will delay the execution thus making it valid.

Please feel free to let us know if you still have any questions.

Thanks!


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.