OnLoadStart, OnLoadEnd, OnLoadError

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

OnLoadStart, OnLoadEnd, OnLoadError

Postby digory » Tue Nov 29, 2016 10:58 am

I want to display an error page when an error occurs during loading. For this, I implemented OnLoadError and used LoadString to load an HTML page tinkered up at runtime, pretty much in the same way as SimpleHandler::OnLoadError does in the cefsimple example app.

However, I noticed a strange behaviour: When navigating to an URL that doesn't exist, the page goes blank, the error page does not show up. When reloading the page through browser->Reload(), the error page would show up. I tried adding methods for OnLoadStart and OnLoadEnd and noticed OnLoadError is called before OnLoadStart! Also, OnLoadEnd always returns HTTP Status 200. Apparently, the LoadString in the OnLoadError causes CEF to get confused about the loading state. Where else should I put LoadString if not in OnLoadError?

There is another oddity: The documentation states that CefLoadHandler callbacks may be called in the browser process or in the renderer process. However, if I add a call to CEF_REQUIRE_UI_THREAD to OnLoadStart, OnLoadEnd and OnLoadError callbacks, the macro never fails, so apparently they're never called in the renderer process.

EDIT: I've just commented out the call to LoadString and realized that even now, OnLoadError is called before OnLoadStart/OnLoadEnd, and OnLoadEnd comes with an HTTP status of 200 even if the requested server does not exist! Is this a bug in CEF or am I doing something wrong?
digory
Expert
 
Posts: 118
Joined: Wed Oct 26, 2016 3:13 am

Re: OnLoadStart, OnLoadEnd, OnLoadError

Postby digory » Wed Nov 30, 2016 3:53 am

I realized that the more sophisticated example cefclient uses LoadURL instead of LoadString, passing the entire page down via Base64-encoded string in the URL. In contrast to LoadString, it works like a charm. Still, the following questions remain:

  • Why is LoadString supported if it doesn't work properly?
  • Why is OnLoadStart called after OnLoadError?
  • Why do I always see HTTP Status 200 in OnLoadEnd even when the server I'm trying to contact does not exist at all?
  • Is there a limit of the size of the HTML text when passing it via URL?
digory
Expert
 
Posts: 118
Joined: Wed Oct 26, 2016 3:13 am

Re: OnLoadStart, OnLoadEnd, OnLoadError

Postby magreenblatt » Wed Nov 30, 2016 1:07 pm

digory wrote:Why is LoadString supported if it doesn't work properly?

This is an open bug. See https://bitbucket.org/chromiumembedded/cef/issues/579.

digory wrote:Why is OnLoadStart called after OnLoadError?
Why do I always see HTTP Status 200 in OnLoadEnd even when the server I'm trying to contact does not exist at all?

The OnLoadStart/OnLoadEnd messages originate from the renderer. I would guess that something has changed in the Chromium implementation such that failed loads are now considered "successful navigation to an empty page". Feel free to add a bug. At a minimum we should update the documentation with the new expectations.

digory wrote:Is there a limit of the size of the HTML text when passing it via URL?

https://bugs.chromium.org/p/chromium/is ... d=44820#c1
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 119 guests