Welcome Guest Search | Active Topics | Sign In | Register

Navigation Events Options
Michael
Posted: Tuesday, June 17, 2014 3:47:19 AM
Rank: Member
Groups: Member

Joined: 6/16/2014
Posts: 25
Hello,

regarding the Webbrowsers navigation events I have a question. In my understanding, every top level window (MainFrame) should fire a LoadComplete-Event. I mean, if I make a "LoadUrl" or click a Link, I have (at least) one BeforeNavigate Event and I should have one LoadComplete Event.
In my tests, the LoadComplete Event is not always fired.

Best regards,
Michael
eo_support
Posted: Tuesday, June 17, 2014 11:10:52 AM
Rank: Administration
Groups: Administration

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

No. That is not the case. LoadComplete event pairs with expicil LoadXXXX (such as LoadUrl) calls. This is because EO.WebBrowser does not track every request --- it only track those you issued through LoadXXXX. For example, LoadUrl returns you a NavigationTask object and setup the internal tracking for the NavigationTask object. You can either wait using the NavigationTask object directly (sync blocking call), or use LoadComplete event to handle it asynchronously.

Other request such as a navigation caused by user clicking a link are not tracked. BeforeNavigate event will be raised for all cases so that your code will have a chance to cancel the request. But there is no event to notify you when this specific request has finished loading. The closest you can get is IsLoadingChanged event. That event will be raised when IsLoading property changes. You can use that event to detect whether the browser is still loading a request.

Thanks!
Michael
Posted: Tuesday, June 17, 2014 11:20:57 AM
Rank: Member
Groups: Member

Joined: 6/16/2014
Posts: 25
Hi,
it behaves like you described. Thank you for your tip, I will try with the IsLoading Event/Property.

Thank you!
eo_support
Posted: Tuesday, June 17, 2014 12:56:33 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
You are very welcome. Please feel free to let us know if you have any more questions.

Thanks!
Craig Oliver
Posted: Tuesday, November 18, 2014 10:13:54 AM

Rank: Advanced Member
Groups: Member

Joined: 7/7/2014
Posts: 60
Along this line, our application seems to sometimes lose the URL when the LoadCompleted event gets triggered.

Top of code:
webView1.Url = sourcepage.ToString();
webView1.LoadCompleted += webView1_LoadCompleted;

....

void webView1_LoadCompleted(object sender, NavigationTaskEventArgs e)
{
log.lvList.Items.Add(string.Format("LoadCompleted: Error: {0}", e.Task.ErrorCode));
log.lvList.Items.Add(string.Format("LoadCompleted: IsAborted: {0}", e.Task.IsAborted));
log.lvList.Items.Add(string.Format("LoadCompleted: URL: {0}", e.Task.Url));
screenReady(e);
}

No error code (OK), but the URL is empty. This then gives an HTTP status code 0 and "The connection was aborted".

This is using the latest EO browser in a WinForm. And it does not happen all the time, but only on some machines. Unfortunately we don't have access to all the machines: this is a click-once application. Our internal testing did not show this issue, and only on a remote terminal server running Windows Server 2012 can we recreate it. But users are experiencing it (so we had to roll back to our previous web engine, which I really, really want to get off of!)

Any assistance would be appreciated.
Let me know if I should open a new thread for this particular option.
eo_support
Posted: Tuesday, November 18, 2014 11:27:11 AM
Rank: Administration
Groups: Administration

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

Please try to use LoadUrl instead of Url. For example:

NavigationTask task = webView1.LoadUrl(sourcePage);

After you have the task object, you can check whether this task object's ID property is the same as the one you see in LoadCompleted event.

Alternatively, you can use WebView.JSInitCode to track page load complete. The basic steps are:

1. Use WebView.RegisterJSExtensionFunction to register a JavaScript extension function;
2. Use WebView.JSInitCode to inject JavaScript code into your page. This code will be called immediately after the context for a new page is created (every time the WebView loads a Url, regardless whether it is initiated by your code or by the user). It is called before other code in the page runs;
3. Inside your WebView.JSInitCode, you can attach your own handler to handle the document object's load event;
4. Inside your handler, you can call the extension function you registered in step 1, this calls back into your .NET code. Make sure your .NET code returns immediately and does not block;

This is more code but it can help you track all load requests, so it may worth a try.

Thanks!
Craig Oliver
Posted: Tuesday, November 18, 2014 1:14:01 PM

Rank: Advanced Member
Groups: Member

Joined: 7/7/2014
Posts: 60
The LoadURL gives the same results. I am working on the 2nd option.

Oddly, though, while testing I've loaded Fiddler up to see the traffic. With Fiddler up, it always works. Without Fiddler, it does not work. When it does not work the NavigateTaskID is always 1 greater than the navigationtaskID from the original:

nTask = webView1.LoadUrl(sourcepage.ToString()); // original task
...
void webView1_LoadCompleted(object sender, NavigationTaskEventArgs e)
{
log.lvList.Items.Add(string.Format("LoadCompleted: taskID: {0} [{1}]", e.Task.ID, nTask.ID)); // e.Task.ID = nTask.ID + 1
...

There is something interesting going on in the network stack, but being unable to observe it makes it complicated (what I call the technician syndrome: works fine if the tech is watching, in this case, Fiddler)
eo_support
Posted: Tuesday, November 18, 2014 1:22:03 PM
Rank: Administration
Groups: Administration

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

I agree with you that there must be something going on in the network stack. Please try to handle the WebView's LoadFailed event and see if you can catch anything there. That might reveal something.

Thanks!
Craig Oliver
Posted: Tuesday, November 18, 2014 1:33:43 PM

Rank: Advanced Member
Groups: Member

Joined: 7/7/2014
Posts: 60
doing that yields the following:

ErrorCode: ConnectionAborted
Message: The connection was aborted.

The URL matches the calling URL. Could there be some sort of race condition? This does work on a lot of computers, but there are enough of them breaking down that is causing the issue. Internally it works on my Windows 8 machine, the QA Win 7 machine, fails on a Windows Server 2012 machine and several unknown (click once) machines in the wild.
Craig Oliver
Posted: Tuesday, November 18, 2014 2:59:25 PM

Rank: Advanced Member
Groups: Member

Joined: 7/7/2014
Posts: 60
sadly the 2nd option did not work either (invoking JS): same error. I just find it most curious that it always works as expected with Fiddler running, and does not when it is not running. It would be helpful to view that traffic to see what is going on when it fails. Still poking away at it though :)
eo_support
Posted: Tuesday, November 18, 2014 3:44:40 PM
Rank: Administration
Groups: Administration

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

This is more likely an issue in the network stack. What happened is, the original request failed because of a network issue (for example, your server abruptly closing the connection is one possibility). When this happens, two thing occurs:

1. LoadFailed event handler is called;
2. Internally, WebView calls LoadHtml to display an error message for this failed event. This triggers the second NavigationTask (with ID one above your task Id). This task obviously will complete successfully, which triggers your LoadComplete event (we should probably skip LoadComplete event for such internal taskes);

In order to troubleshoot such problem, you must get a network monitor to monitor the network traffic directly (you can try WireShark). Fiddler won't work for such cases because it acts like a proxy in between, so it might just somehow fix the connections. You can also try to point the WebView to a different page/server to see if you see the same problem. The problem maybe related to SSL.

Thanks!
Craig Oliver
Posted: Wednesday, November 19, 2014 7:50:49 AM

Rank: Advanced Member
Groups: Member

Joined: 7/7/2014
Posts: 60
thanks - I'l try Wireshark to see what is going on. This is just a wrapper for our EHR site, so it only goes to 1 site.
eo_support
Posted: Wednesday, November 19, 2014 9:55:20 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
No problem. Please keep us updated.
Craig Oliver
Posted: Wednesday, November 19, 2014 11:17:28 AM

Rank: Advanced Member
Groups: Member

Joined: 7/7/2014
Posts: 60
I may have found the issue. When running with Fiddler (proxy) all works. Without Fiddler, it does not. The only difference I can see is that when Fiddler runs, TLS uses both 1.2 and 1.1; without Fiddler it always uses TLSv1.2. So apparently it needs to drop back to 1.1 for some reason. It may be that we are not supporting TLS1.2 on our servers yet (checking with operations).

However - this is a guess: I am not a network engineer, but that was the only differences I could spot in the traffic flow. Still looking though: there is a lot of information to sift through from Wireshark!

Edit: in looking at our site directly via Chrome, it does indicate that it had to drop to 1.1. I've tried a few other sites that are 1.2 and the EO browser works perfectly. So there is potentially an issue with our site and the TSL1.2 side of things.

Edit 2: just to reiterate, on some machines it works just fine by itself (i.e., no Fiddler). My current theory is that it may depend on the OS and its current updates and networking a bit: we know it works on our local Win7 & Win8 machines, not a Win Server 2012. But some users using Win7 it works, some not.
Craig Oliver
Posted: Friday, November 21, 2014 3:48:45 PM

Rank: Advanced Member
Groups: Member

Joined: 7/7/2014
Posts: 60
Turns out our servers did not handle TLSv1.2 and would drop back to 1.1. Apparently some Windows machines handle the degradation correctly, some don't (and our QA machines all worked of course!)

We're in the process of correcting that, and on our test environments (once we found a machine configuration that would fail) the server update corrected the issue.
eo_support
Posted: Friday, November 21, 2014 10:52:20 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
Thank you very much for the update. I am glad that your team worked out the problem. Please feel free to let us know if there is anything else.


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.