Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Ignore callbacks if the browser instance has been deleted #282

Merged
merged 1 commit into from
Jul 22, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions appshell/client_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,19 @@ bool ClientApp::OnProcessMessageReceived(
CefRefPtr<CefV8Value> callbackFunction = callback_map_[callbackId].second;
CefV8ValueList arguments;
context->Enter();

for (size_t i = 1; i < messageArgs->GetSize(); i++) {
arguments.push_back(ListValueToV8Value(messageArgs, i));

// Sanity check to make sure the context is still attched to a browser.
// Async callbacks could be initiated after a browser instance has been deleted,
// which can lead to bad things. If the browser instance has been deleted, don't
// invoke this callback.
if (context->GetBrowser()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the difference between what is returned here and what is passed into this function? I almost think we should be checking what's passed in since we use it in the else case for the outer if to get a pointer to the brackets js api.

Otherwise I think this change is fine -- just trying to explore solutions for other CEF crashers...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the mac reload crash scenario, the passed in browser parameter and browser.get() were both non-null. The only test that prevented the crash was context->GetBrowser().

for (size_t i = 1; i < messageArgs->GetSize(); i++) {
arguments.push_back(ListValueToV8Value(messageArgs, i));
}

callbackFunction->ExecuteFunction(NULL, arguments);
}

callbackFunction->ExecuteFunction(NULL, arguments);
context->Exit();

callback_map_.erase(callbackId);
Expand Down