After I make a call to browser->GetMainFrame()->LoadURL(), I see in the logs that
CefRenderProcessHandler::OnBrowserDestroyed() is being called. This call destroys
javascript bindings for given browser in my app and is not an expected behavior. The
LifespanHandler::OnBeforeClose() is not being called in this case. Also, the navigateUrl
passed to CreateBrowserSync() is "google.com", and the url passed to LoadURL() is
"google.com" as well.
Why is OnBrowserDestroyed() being called, is this some bug?
EDIT. OnBrowserDestroyed() is sometimes not being called, looks like a random behavior.
EDIT 2. I tried to fix it by setting javascript bindings again after the call to LoadURL(),
but seems there is an another bug in CEF that makes this impossible in an appropriate
timing. The problem is when calling CefBrowser.GetFrameIdentifiers(), it returns a
vector with frameId=0, which is an invalid frame. I'm calling GetFrameIdentifiers in
CefRenderProcessHandler::OnProcessMessageReceived().
EDIT 3. The fix for GetFrameIdentifiers() bug is to call browser->GetMainFrame()->GetIdentifier(),
then I get correct id. After the LoadURL() and OnBrowserDestroyed() callback is called, the
browser window seems to lose the focus and I have to call SendFocusEvent() again.
EDIT 4. When website contains many iframes then the GetFrameIdentifiers() bug is a serious problem.
It seems to always return an empty vector with all frame identifiers equal to 0. I've tried to post a
delayed task to call GetFrameIdentifiers at a later time, but it's the same, GetFrameIdentifiers still
doesn't work.
EDIT 5. I've found a fix to the GetFrameIdentifiers() problem. Using GetFrameNames() instead.
Though its documentation should be updated:
https://code.google.com/p/chromiumembed ... r=1448#176
- Code: Select all
///
// Returns the names of all existing frames.
///
/*--cef()--*/
virtual void GetFrameNames(std::vector<CefString>& names) =0;
This is not true, it does not return the main frame.
EDIT 6. Found an another solution to the OnBrowserDestroyed() problem. Doing a javascript
navigation by executing "location='http://...'" instead of the LoadURL(), does not causes
the OnBrowserDestroyed() callback to be fired.
Using CEF 3 branch 1453 revision 1352 on Ubuntu 12.04 64-bit.
Best regards,
Czarek