-
Notifications
You must be signed in to change notification settings - Fork 468
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
OnContextCreated may not always be called in renderer process #3823
Comments
I see a similar problem, but it hasn't been resolved yet: OnContextCreated not always called when LoadUrl causes creation of new Renderer process · Issue #485 · cztomczak/cefpython · GitHub |
Sometimes it's difficult to reproduce even after opening the application many times, and sometimes it's easy to reproduce.
What URL are you loading? Is it the same URL every time?
|
the URL is a website for our internal services. Yes, it is the same URL every time. |
OnContextCreated will only be called in cases where the frame source contains JavaScript code. When OnContextCreated is not called for you has your URL loaded correctly, and has it loaded/executed JavaScript code? |
Do you always create window.external (every call to OnContextCreated) or is it conditional?
|
yes, when opening my application, the OnContextCreated function should be called, and the window.external should be created every call. So It's just strange that the window.external is empty sometimes. |
Hi, @magreenblatt |
I'll leave this issue open, but it's unlikely to be addressed without clear and reliable reproduction steps. |
class CefClientApp : public CefApp,
public CefRenderProcessHandler {
public:
virtual CefRefPtr GetRenderProcessHandler()
override { return this; }
}
the class CefClientApp inherits from Class CefRenderProcessHandler,I will register some methods in function OnContextCreated:
void CefClientApp::OnContextCreated(CefRefPtr browser,
CefRefPtr frame,
CefRefPtr context)
{
auto object = context->GetGlobal();
auto externalObj = CefV8Value::CreateObject(nullptr, nullptr);
object->SetValue("external", externalObj, V8_PROPERTY_ATTRIBUTE_NONE);
CefRefPtr cefV8Handler = new CefV8Client();
// the WebExtFunc:: is my defined functions list, the following method is registering the function
for (int i = 0; i < WebExtFunc::NameCount; i++)
{
externalObj->SetValue(WebExtFunc::Names[i], CefV8Value::CreateFunction(WebExtFunc::Names[i], cefV8Handler.get()), V8_PROPERTY_ATTRIBUTE_NONE);
}
}
A very random issue:
Sometimes it's difficult to reproduce even after opening the application many times, and sometimes it's easy to reproduce.
I opened the application multiple times and found that the function list registered under window.external was empty.
Expected behavior
Every time the application is opened, the function list in window.external can be registered normally in the renderer process.
Versions (please complete the following information):
The text was updated successfully, but these errors were encountered: