Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(489)

Unified Diff: ios/web_view/internal/cwv_web_view.mm

Issue 2826663002: Fix a crash bug on deallocating CWVWebView. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web_view/internal/cwv_web_view.mm
diff --git a/ios/web_view/internal/cwv_web_view.mm b/ios/web_view/internal/cwv_web_view.mm
index a29d623d9d2bc1d9f2321e5f95f3831bf8fbaff7..157ed90a02db5844d0c3e00e02864434d63738ae 100644
--- a/ios/web_view/internal/cwv_web_view.mm
+++ b/ios/web_view/internal/cwv_web_view.mm
@@ -39,6 +39,23 @@ NSString* const kSessionStorageKey = @"sessionStorage";
}
@interface CWVWebView ()<CRWWebStateDelegate, CRWWebStateObserver> {
+ // |_configuration| must come before |_webState| here to avoid crash on
+ // deallocating CWVWebView. This is because the destructor of |_webState|
+ // indirectly accesses the BrowserState instance, which is owned by
+ // |_configuration|.
+ //
+ // Looks like the fields of the object are deallocated in the reverse order of
+ // their definition. If |_webState| comes before |_configuration|, the order
+ // of execution is like this:
+ //
+ // 1. |_configuration| is deallocated
+ // 1.1. BrowserState is deallocated
+ // 2. |_webState| is deallocated
+ // 2.1. The destructor of |_webState| indirectly accesses the BrowserState
+ // deallocated above, causing crash.
+ //
+ // See crbug.com/712556 for the full stack trace.
+ CWVWebViewConfiguration* _configuration;
std::unique_ptr<web::WebState> _webState;
std::unique_ptr<web::WebStateDelegateBridge> _webStateDelegate;
std::unique_ptr<web::WebStateObserverBridge> _webStateObserver;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698