cefsharp / CefSharp

.NET (WPF and Windows Forms) bindings for the Chromium Embedded Framework
http://cefsharp.github.io/
Other
9.82k stars 2.92k forks source link

issues about ChromiumWebBrowser.Load(url) #2406

Closed baby-Jie closed 6 years ago

baby-Jie commented 6 years ago

my code: browser.Load(url); if (!url.Equals("about:blank")) { browser.Load(url); browser.BringToFront(); }

  switch url betweeen "about:blank" and "www.baidu.com" some times
 i find it cannot turn to "www.baidu.com" from "about:blank"

Notes: When the page is in the about:blank state, Load(url) twice , it will go wrong

welcome[bot] commented 6 years ago

Welcome! If you're reporting a bug, please make sure you have completed the bug report template see https://github.com/cefsharp/CefSharp/blob/master/ISSUE_TEMPLATE.md#bug-report. Please make sure you provide enough detail that someone else can reproduce the issue you are experiencing. We prefer to keep this issue track just for bug reports. If you have a question or need help with something I'd ask that you self close this issue and have a read over https://github.com/cefsharp/CefSharp/blob/master/ISSUE_TEMPLATE.md it contains background information, details on where to ask your questions (hint, Gitter is one such place) It's also reportant to remember that CefSharp is just a wrapper around the Chromium Embedded Framework(CEF), a lot of questions people have aren't actually CefSharp specific, they're generic to CEF and for those CEF has it's own support forum at http://magpcss.org/ceforum/index.php and issue tracker at https://bitbucket.org/chromiumembedded/cef

amaitland commented 6 years ago

How do I investigate my issue further?

It's important to remember that CefSharp is just a wrapper around the Chromium Embedded Project (CEF), the upstream CEF forum is a valuable resource. Also CEF has it's own Issue Tracker. Please take the time to research your own problem, including Googling, searching on ceforum, etc.

--

Finding more info

--

How do I download cefclient?

This next part is key

baby-Jie commented 6 years ago

@amaitland hello amaitland, i am using WinForms.The verision i am using is "3.3239.1723"(63.0.3). it's simple in my code: private void btnGo_Click(object sender, EventArgs e) { string url = textBox1.Text.Trim(); browser.Load(url); //Thread.Sleep(30); browser.Load(url); } change the url:
1,"www.google.com" -> "about:blank" 2, "about:blank" -> "www.google.com" it does not work at step 2, it also at the page of "about:blank", but if i use Thread.Sleep between Load(Url), it will work properly.

there is no useful information in debug.log. it only write dome warning when the browser start like this: [0605/095707.569:WARNING:angle_platform_impl.cc(51)] rx::HLSLCompiler::compileToBinary(228): C:\fakepath(30,8-58): warning X3571: pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them C:\fakepath(35,8-28): warning X3571: pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them

[0605/095708.579:WARNING:angle_platform_impl.cc(51)] rx::HLSLCompiler::compileToBinary(228): C:\fakepath(48,8-58): warning X3571: pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them C:\fakepath(53,8-28): warning X3571: pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them

can you give me some suggestions about how to deal with it?

amaitland commented 6 years ago

about:blank is treated as a special case by Chromium, in newer version I don't believe it triggers a navigation.

http://magpcss.org/ceforum/viewtopic.php?f=6&t=15989&p=38465&hilit=about%3Ablank#p38465 http://magpcss.org/ceforum/viewtopic.php?f=10&t=15950&p=38246&hilit=about%3Ablank#p38246

From a CefSharp point of view this is unlikely a bug. You should test with cefclient if you wish to confirm, see above for details.

You can always use a data encoded uri, see https://github.com/cefsharp/CefSharp/wiki/General-Usage#loading-htmlcssjavascriptetc-from-diskdatabaseembedded-resourcestream for an example, it's at the bottom of that section

https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs

baby-Jie commented 6 years ago

@amaitland it's ok, thanks a lot

amaitland commented 6 years ago

You can try with 65.0.0-pre01 and see if it behaves differently, in general I suggest avoiding using about:blank

baby-Jie commented 6 years ago

@amaitland hello, i find another problem. first: browser.Load(blankHtmlFilePath); second: //browser.Load("www.google.com"); //browser.Load("www.google.com"); browser.Load(testHtmlFilePath); browser.Load(testHtmlFilePath);

At the second part, it does not work. If i load "www.google.com", it is ok. if i use data encoded uri at the first step, suach as : const string html = "Test"; var base64EncodedHtml = Convert.ToBase64String(Encoding.UTF8.GetBytes(html)); browser.Load("data:text/html;base64," + base64EncodedHtml); testhtml will not load completely, i need refresh the browser.

baby-Jie commented 6 years ago

@amaitland I try it in cefclient(3.3239.1723"). It also exists this problem. And all is ok in 65.0.0-pre01