Back Issue OnLoadError rendering with LoadUrl best approach?

Do not post support requests, bug reports or feature requests. Discuss CEF here. Non-CEF related discussion goes in General Discussion!

Back Issue OnLoadError rendering with LoadUrl best approach?

Postby mitchc » Mon Dec 09, 2019 11:51 am

With recent changes using LoadString for error handling was ruled a bad idea:
https://bitbucket.org/chromiumembedded/ ... ce-and-get
https://bitbucket.org/chromiumembedded/ ... imple-when
https://bitbucket.org/chromiumembedded/ ... -makes-the

and was removed in newer commits all together.

LoadUrl with a base64 encoded error message seemed like a good stop gap for displaying OnLoadError messages to the user.

The problem with this is is LoadUrl adds a new navigation entry to history as well. When this is mixed with the fact there is only GoBack/GoForward short of walking the history tree then manually navigating back to the entry from two before there is not a great way to support the back button properly.

Currently assuming a non temporal error OnLoadError is called when visiting errorsite.com this then leads to LoadUrl being called with the error message causing bath in the history stack. Hitting back navigates again to errorsite.com which immediately would cause OnLoadError to trigger resulting in the user being stuck.

A work around is to detect on an error page and inject javascript of history.go(-2) on back request which works but is clumsy to a degree.

The cleanest options would seem:
1) Rendering an error page outside of the browser itself
2) On option to not add (or to remove) entries from the navigation history, so back works as expected
3) To intercept the error earlier in the chain and return custom text for the page as is bypassing OnLoadError.
mitchc
Newbie
 
Posts: 5
Joined: Wed Apr 25, 2018 4:26 pm

Re: Back Issue OnLoadError rendering with LoadUrl best appro

Postby mitchc » Mon Dec 09, 2019 12:39 pm

The LoadUrl is used by the sample client for example:
https://bitbucket.org/chromiumembedded/ ... ler.cc-149

so it is subject to the same issue (browser to a invalid domain for example and try to go back).
mitchc
Newbie
 
Posts: 5
Joined: Wed Apr 25, 2018 4:26 pm

Re: Back Issue OnLoadError rendering with LoadUrl best appro

Postby magreenblatt » Mon Dec 09, 2019 1:06 pm

You raise valid points. See the comment at https://bitbucket.org/chromiumembedded/ ... t-52020179
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Back Issue OnLoadError rendering with LoadUrl best appro

Postby aleitner » Fri Jan 26, 2024 9:58 am

I am also encountering this exact same issue at the moment with my application. Is there a way to either delete a navigation entry or prevent a navigation entry from being added to history? I am unable to see the comment at the url mentioned below.

magreenblatt wrote:You raise valid points. See the comment at https://bitbucket.org/chromiumembedded/ ... t-52020179
Last edited by aleitner on Fri Jan 26, 2024 10:38 am, edited 1 time in total.
aleitner
Techie
 
Posts: 49
Joined: Fri Jun 16, 2023 12:05 pm

Re: Back Issue OnLoadError rendering with LoadUrl best appro

Postby magreenblatt » Fri Jan 26, 2024 10:30 am

The updated issue URL is https://github.com/chromiumembedded/cef/issues/2586. I’m not sure which specific comment was linked at the time.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Back Issue OnLoadError rendering with LoadUrl best appro

Postby magreenblatt » Fri Jan 26, 2024 10:33 am

Is there a way to either delete a navigation entry or prevent a navigation entry from being added to history?

It may be possible via JavaScript, see https://stackoverflow.com/questions/200 ... 0#20044710
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Back Issue OnLoadError rendering with LoadUrl best appro

Postby amaitland » Fri Jan 26, 2024 3:36 pm

Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1290
Joined: Wed Jan 14, 2015 2:35 am

Re: Back Issue OnLoadError rendering with LoadUrl best appro

Postby aleitner » Tue Jan 30, 2024 10:32 am

amaitland wrote:Try DevTools Page.setDocumntContent to load content without performing a navigation.

https://chromedevtools.github.io/devtoo ... entContent

You can look at https://github.com/cefsharp/CefSharp/blob/bbe7260fe8d0fa4507cf0e36dea36ffe63b35f91/CefSharp.WinForms.Example/BrowserTabUserControl.cs#L232 for some inspiration.


Does the libcef capi also provide the ability to invoke setDocumentContent?
aleitner
Techie
 
Posts: 49
Joined: Fri Jun 16, 2023 12:05 pm

Re: Back Issue OnLoadError rendering with LoadUrl best appro

Postby aleitner » Tue Jan 30, 2024 10:09 pm

Until I can figure out a way to use Page.setDocumentContent, I'm just manually writing the html to the document using execute_java_script.

Code: Select all
"document.open();"
"document.write('<html>Uh oh... I errored......</html>);"
"document.close();
aleitner
Techie
 
Posts: 49
Joined: Fri Jun 16, 2023 12:05 pm

Re: Back Issue OnLoadError rendering with LoadUrl best appro

Postby amaitland » Sat Feb 10, 2024 8:35 pm

Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1290
Joined: Wed Jan 14, 2015 2:35 am


Return to CEF Discussion

Who is online

Users browsing this forum: Google [Bot] and 24 guests