-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error while fulfilling of JS: Request BrowserId : 1 not found it's likely the browser is already closed #4621
Comments
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as off-topic.
This comment was marked as off-topic.
It seems that happening with only some Websites. |
good day @amaitland |
@netmaxik have you tried the new v121.3.x ? Has the issue been resolved @amaitland ? |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Modified Google test to replicate this issue: cefsharp#4621
Not sure if this was what I was supposed to do (I've never done this before), but I forked the entire master branch, changed the offscreen test cs file, included the part which causes an exception, and initialized pull request on this one single file from my fork: #4741 I could not get it to compile or run though, there was a whole bunch of errors in the C++ sources which I'm unfamiliar with, so I could not see if the test truly replicates the issue described here, but I did test it in async fashion as well in the original test I sent you, and it did produce the same exception, so hopefully you'll be able to replicate the issue on your end and see what's causing it in the first place, so we can get this resolved. Thank you. |
For the example provided by @nebojsasandin you can forcibly isolate the origins and the script executes correctly. settings.CefCommandLineArgs.Add("isolate-origins", "https://accounts.google.com,https://chrome.google.com,https://chromewebstore.google.com"); |
Loading In the So CEF doesn't have the same google urls isolated like You can add the following command line arg to mimic the Chrome behaviour. settings.CefCommandLineArgs.Add("isolate-origins", "https://accounts.google.com,https://chrome.google.com,https://chromewebstore.google.com"); |
I've created chromiumembedded/cef#3672 to see if Until then you can use the workaround I've listed above.
@ficho-hun Did you observe the issue on websites other than the google ones?
@netmaxik If you are still experiencing this issue then please test with the workaround provided in #4621 (comment) |
@amaitland I did test with : settings.CefCommandLineArgs.Add("isolate-origins", "https://accounts.google.com,https://chrome.google.com,https://chromewebstore.google.com");. What I found out is :
|
@netmaxik Have you tried adding more domains to the list? In my use-case I had to add few extra domains: |
@nebojsasandin I did most off them.. nothing help. I do not know how to create test units... so do not know my next steps. But issue still continue :(. @amaitland Im sorry I cannot create Test Units. I did not know how to do that. :( And now really do not have time to learn and understand that :( really sorry.. |
New test to mimic issue cefsharp#4621 where isolate-origins settings does not help.
@netmaxik , when I test your code based on the instructions you provided (click on Test button, then navigate to Sign In, it still works when I include "https://www.google.com" to the isolate-origins).
...However, I realized that there are still issues with this even with the workaround. So maybe that's what you're talking about.
|
The problem is in the Starting in I've added both tests (they'll only run locally, not on In
@nebojsasandin Thanks for providing the tests 👍 The problem is likely in the |
The above-mentioned issue still persists. Does anyone have a solution?
I am unsure whether this is a default behavior change in CEFSharp or a bug. |
True, I'm randomly getting this error after upgrading to latest version EDIT: or maybe not so randomly! It happens every 10 minutes, accurately. I'm checking a URL every 3 seconds - in short, I do: while (true) { Every 10 minutes I get that error when running the JS call. A dirty workaround for me is to redirect to another page by clicking on a button in the same page, so let's say there's a "go to my profile" button, I press that, and after going to my profile, I can Browser.Load(url) and everything keeps working fine for another solid 10 minutes. |
Well it seems to be fixed if you specifically set ChromeRuntime=false in your settings. At least this worked for me after upgrading, and everything seems to be working alright. |
I have also been experiencing the same issue with ChromeRuntime=true on random websites. It's not just related to Google websites. I found it on: https://www.visualcom.pl/kontakt/wymagania-plikow-produkcyjnych' |
If the problem only occurs when using the https://github.com/chromiumembedded/cef/issues The alloy bootstrap will be removed in
@GrabzIt Can you please create a unit test that reproduces the problem you are seeing (and submit a PR). There are already tests at
To set expectations, I've not seen anything here that suggests this is an issue that can be fixed directly in I potential workaround would be to switch to using https://github.com/cefsharp/CefSharp.Dom?tab=readme-ov-file#dom-access Hopefully at some point CEF will add equivalent functionality directly (chromiumembedded/cef#3631) |
I have found that the errors happen after a long period of time, so hours or days, then carry on happening. So this isn't something that is suitable for a unit test. I am going to try and use the Chrome DevTools Protocol to see if that fixes the issue. |
Not on my specific case - they were after 10 solid minutes - but it's funny it's time dependant. |
yes also to me afte 10 minutes, dont know why this timing. (rendering working, on paint work, just JS code dont work) |
I feel this is Google's way of breaking Chrome Extensions that need (JS level magic to do stuff like hide ads.) |
EDIT: While this helped with the severity of the issue, it didn't actually solve it, I still have to naviage away and then back to the page I need I had this error in another site, I "possibly" managed to fix it by turning off chromeruntime from the CefSharp Settings ` CefSharp.WinForms.CefSettings se = new CefSharp.WinForms.CefSettings(); ` |
Now they remove this "se.ChromeRuntime = false;" and i cant run my aplication! :\ start getting that error "Message = "Request BrowserId : 1 not found it's likely the browser is already closed"" |
I also have this issue. Did you find any workaround? |
no :\
Nuno ***@***.***> escreveu (quinta, 3/10/2024 à(s) 13:37):
… Now they remove this "se.ChromeRuntime = false;" and i cant run my
aplication! :\ start getting that error "Message = "Request BrowserId : 1
not found it's likely the browser is already closed""
I also have this issue. Did you find any workaround?
—
Reply to this email directly, view it on GitHub
<#4621 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJAU5TAVZK7GEKQMIQ5GXXTZZU3CHAVCNFSM6AAAAAA6ZJMBUKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOJRGMYTGMZTHA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Please create a unit test inside the There are already tests at
Until there's a unit test that reproduces the problem there's not really anything actionable here. |
This is still an issue in 130.1.90.0 only when using Steps
CEFSharp is entirely broken with this change, happy to provide any assistance to track it down. |
But from what I understand, ExecuteScriptAsync doesn't return any data, and I need to get data from the browser. If I am right, than I cannot use that alternative. |
@nuno84 |
@aimcosoftware Can you turn that into a I need a reliable way to reproduce the problem. |
Edit: The problem below does not appear if the two apps are hosted on different sites (and http://localhost:4200 and http://localhost:4201 are considered to be the same site according to https://www.chromium.org/Home/chromium-security/site-isolation/). To have it working as expected I access one app with localhost and the other using the hostname. This helped me get on for now until its is fixed in CEFSharp. ---Originial post--- I am experiencing this issue as well and I though I'd share my context here in case it could be of any help in finding a way to fix or mitigate the problem. In my case I run
I have tried with Version: |
As above, I need more than just a list of steps to reproduce the problem, ideally a unit test, a fork of the minimal example would be ok I guess (would need to be turned into a unit test). |
The key seems to be that you need to have two web applications served from the same "site" (where site is the scheme and registered domain name, including the public suffix, but ignoring subdomains, port, or path). These could probably be simple html-pages with links to navigate between the apps. The CEFSharp application should just run |
Here is a pretty minimal example. Originally I used a totally non google set of urls that loaded more resources and would crash in 3 loads, but even just using some google.com pages it can happen for me at least in 5 ever time. The code in short: public MainWindow() {
InitializeComponent();
Loaded += MainWindow_Loaded;
}
private ChromiumWebBrowser browser;
private string theUrl = "https://google.com";
private string theUrl2 = "https://google.com/404";
private string theUrl3 = "https://google.com/503";
private async void MainWindow_Loaded(object sender, RoutedEventArgs e) {
CefSharpSettings.RuntimeStyle = CefRuntimeStyle.Chrome;
CefSettings settings = new() { CachePath = null, RootCachePath = @"x:\sandbox\test\trash_cache2", };
Cef.Initialize(settings);
browser = new ChromiumWebBrowser();
contentCntrl.Content = browser;
await Task.Delay(1000);
await browser.NavigateTo(theUrl);
var res = await browser.EvaluateScriptAsync<string>("5*6;");
Log(res);
await browser.NavigateTo(theUrl2);
res = await browser.EvaluateScriptAsync<string>("5*6;");
Log(res);
await browser.NavigateTo(theUrl3);
res = await browser.EvaluateScriptAsync<string>("5*6;");//original site generally throws here
Log(res);
await browser.NavigateTo(theUrl2);
res = await browser.EvaluateScriptAsync<string>("5*6;");
Log(res);
await browser.NavigateTo(theUrl);
res = await browser.EvaluateScriptAsync<string>("5*6;");//for google sites throws here
Log(res);
await browser.NavigateTo(theUrl2);
res = await browser.EvaluateScriptAsync<string>("5*6;");
Log(res);
}
private void Log(string res) {
Debug.WriteLine(res);
}
}
public static class helpers {
public static async Task NavigateTo(this ChromiumWebBrowser browser, String url) {
browser.Address = url;
await browser.WaitForNavigationAsync(TimeSpan.FromSeconds(30));
await Task.Delay(1000);
}
} Full project: |
It also doesn't need 3 urls just navigating from 1 to 2 and back to 1 generally works too. |
I realize there is a lot of talk around google related domains so a shorter example using google domains probably wasnt the best bet. Here is something that is certainly not loading google:) private string theUrl = "https://brave.com/";
private string theUrl2 = "https://brave.com/search/";
private async void MainWindow_Loaded(object sender, RoutedEventArgs e) {
CefSharpSettings.RuntimeStyle = CefRuntimeStyle.Chrome;
CefSettings settings = new() { CachePath = null, RootCachePath = @"x:\sandbox\test\trash_cache2", };
Cef.Initialize(settings);
contentCntrl.Content = browser = new ChromiumWebBrowser();
await Task.Delay(1000);
string res;
for (var x = 0; x < 20; x++) {
await browser.NavigateTo(x % 2 == 0 ? theUrl : theUrl2);
res = await browser.EvaluateScriptAsync<string>($"{x}+1");
Log(res);
}
} it can trigger it by the 8th load.
|
@mitchcapper Exactly what I needed, thank you! public async Task NavigateBetweenTwoUrlsBreaksJs()
{
const string theUrl = "https://brave.com/";
const string theUrl2 = "https://brave.com/search/";
using (var browser = new ChromiumWebBrowser(theUrl, useLegacyRenderHandler: false))
{
var response = await browser.WaitForInitialLoadAsync();
await Task.Delay(1000);
for (var x = 0; x < 20; x++)
{
await browser.LoadUrlAsync(x % 2 == 0 ? theUrl : theUrl2);
var javascriptResponse = await browser.EvaluateScriptAsync($"{x}+1");
Assert.True(javascriptResponse.Success, javascriptResponse.Message);
Assert.Equal(x + 1, (int)javascriptResponse.Result);
}
}
} |
Interestingly the settings.CefCommandLineArgs.Add("disable-back-forward-cache"); This is a very specific case, so not sure if that's going to work in other instances. It might be worth trying for some of you. |
Thanks! This fixes our issue at least! |
Is there an existing issue for this?
CefSharp Version
117.2.40
Operating System
Windows 10
Architecture
x64
.Net Version
.net 6.0
Implementation
OffScreen
Reproduction Steps
Version: Above 108
Steps:
Create instance of CefSharp.OffScreen.ChromiumWebBrowser
br = CefSharp.OffScreen.ChromiumWebBrowser();
Go by url 2 times:
br.Load(url)
await br.EvaluateScriptAsPromiseAsync(script);
br.Load(url)
await br.GetSourceAsync();
br.Load(url)
Fulfill JS
_browser.EvaluateScriptAsPromiseAsync(script)
Expected behavior
Fulfilling of JS
Actual behavior
JS Error Request BrowserId : 1 not found it's likely the browser is already closed
Regression?
After regression to version 108 problem dissapeared.
Known Workarounds
Likely problem is here
https://github.com/cefsharp/CefSharp/blob/master/CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cpp
Look at history..
Does this problem also occur in the CEF Sample Application
Yes using WPF/OffScreen command line args
Other information
No response
The text was updated successfully, but these errors were encountered: