Welcome Guest Search | Active Topics | Sign In | Register

channel is invalid - Exception thrown: 'EO.WebBrowser.JSInvokeException' Options
Sven Dhaens
Posted: Tuesday, September 1, 2015 6:26:03 AM
Rank: Member
Groups: Member

Joined: 5/20/2015
Posts: 11
Hi,

I am using WebbBrowser in a application to display a googlemap in Windows.forms.
The WebView is created using a pictureboxHandle and is assigned using the LoadUrlAndWait(html page containing javascript)

Everything works fine, uptill a point:

The application auto-updates the markers displayed on the map every so often using webView.GetDOMWindow().InvokeFunction("InitializeLayer");

This requires no user activity, only the application itself keeps giving commands to the webview.

After a while the application gets stuck on this "channel is invalid" .. and the webView seems to blue-screen or get stuck.
Any sollution? Anything to do with no-user activity? Am I overlooking something?

Maybe this info helps ...
Sven Dhaens
Posted: Wednesday, September 2, 2015 4:37:53 AM
Rank: Member
Groups: Member

Joined: 5/20/2015
Posts: 11
I found this...
JSInvokeResult
InvalidChannel aparrently means: unable to communicate with the browser engine.

& then this...
eo.webbrowser destroyed?
eo_support wrote:

Hi,

When the browser engine crashes, your WebView will be automatically destroyed, which will trigger WebView.Closed event. So you can handle that event to recreate the WebView. This is similar to Chrome browser's "auto restart tab" feature.

Thanks!


Trying this now...


Would be nice If I could prevent browser engine from crashing though.
eo_support
Posted: Wednesday, September 2, 2015 11:18:19 AM
Rank: Administration
Groups: Administration

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

EO.WebBrowser is based on Google's Chromium browser engine and it's a huge project. The browser engine does crash sometimes (even Google's Chrome browser crashes sometimes and displays a "Hey Jim he is dead" message). So it is not practical to expect all crashes to be completely elimiated. However we will still do our best to:

1. Elimiate all crashes in our code or caused by your code (for example, you indeed destroyed the WebView in your code). If you can reproduce the crash, please let us know the steps and we will try the steps here and see if it crashes in our code. Most of the time if we can reproduce it we can find the root cuase and a solution;

2. For other crashes scenarios, you would want to try to implement a recover strategy. For example, Google Chrome would try to restart the page when that page crashed. You can try the same;

Thanks
Sven Dhaens
Posted: Thursday, September 3, 2015 8:09:43 AM
Rank: Member
Groups: Member

Joined: 5/20/2015
Posts: 11
Can I use QueueScriptCall or something to make different functions like

webView.GetDOMWindow().InvokeFunction("InitializeLayer");

stack up in a queue and be performed ASAP but synchronously?
Sven Dhaens
Posted: Friday, September 4, 2015 9:24:52 AM
Rank: Member
Groups: Member

Joined: 5/20/2015
Posts: 11
eo_support wrote:
Hi,

EO.WebBrowser is based on Google's Chromium browser engine and it's a huge project. The browser engine does crash sometimes (even Google's Chrome browser crashes sometimes and displays a "Hey Jim he is dead" message). So it is not practical to expect all crashes to be completely elimiated. However we will still do our best to:

...

Thanks


I understand, I didnt mean to be rude or anything.

Anyway I think I found out what my problem was. In my application events get triggered. these Events do the JSInvokeFunction(...)

These events sometimes trigger in quick succesion, all with their own JSInvokeFunction(). The webbrowser apparently interupts the previous JSInvokeFunction() while recieving a new one. (I needed them synchronous without interuption). Sometimes resulting in applying different functionality to the same objects at once. This triggered conflict in the Javascript objects, eventually crashing the webView.

I ended up using a queing system on the JSInvokeFunctions. This way they get called in order without any problems.
So this is what I added to my Class containing the webView:

Code: C#
using System.Collections.Generic;
....
private Queue<Action> queue = new Queue<Action>();
private bool creatinglayer=false;


Then... where events are triggered I use
Code: C#
queue.Enqueue(() =>{
                        webView.GetDOMWindow().InvokeFunction("InitializeLayer", new object[] {....});
});
ClearQueue();


And finally the function that performs the Actions stored in the queue synchronously.

Code: C#
private void ClearQueue() {
            
            if (clearingQueque == false)
            {
                clearingQueque = true;
                while (queue.Count != 0)
                {
                    Action action = queue.Dequeue();
                    action(); 
                }
                clearingQueque = false;
            }
}


Thanks.
eo_support
Posted: Friday, September 4, 2015 3:36:32 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,066
This makes perfect sense. Thank you very much for sharing!


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.