From 8b5513ed9677c154df7f0da9ca409e9e06437722 Mon Sep 17 00:00:00 2001 From: Deep Shah Date: Thu, 14 Nov 2019 12:14:02 +0530 Subject: [PATCH] Fixing a crash in iOS 9.3.5 when we have a layer with WebView getting deallocated (#20285) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * In case of iOS 9.3.5 when we show a web view and deallocate the layer it is trying to release memory associated with WKWebView instance, but it hadn’t retained it in the first place. This results in a crash. This commit fixes that crash. * Removing the autorelease and retain parts from the WKWebView instantiation. * Changes so that we can remove the retain from the property declaration and depend only on manual retain and release of memory --- cocos/ui/UIWebView/UIWebViewImpl-ios.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/ui/UIWebView/UIWebViewImpl-ios.mm b/cocos/ui/UIWebView/UIWebViewImpl-ios.mm index 2335e113fbdb..e2c448249e3f 100644 --- a/cocos/ui/UIWebView/UIWebViewImpl-ios.mm +++ b/cocos/ui/UIWebView/UIWebViewImpl-ios.mm @@ -82,7 +82,7 @@ - (void)setScalesPageToFit:(const bool)scalesPageToFit; @interface UIWebViewWrapper () -@property(nonatomic, retain) WKWebView *wkWebView; +@property(nonatomic) WKWebView *wkWebView; @property(nonatomic, copy) NSString *jsScheme; @end @@ -118,7 +118,7 @@ - (void)dealloc { - (void)setupWebView { if (!self.wkWebView) { - self.wkWebView = [[[WKWebView alloc] init] autorelease]; + self.wkWebView = [[WKWebView alloc] init]; self.wkWebView.UIDelegate = self; self.wkWebView.navigationDelegate = self; }