From 2db83403ce01f2af00ad633ff5af0948eecdbe91 Mon Sep 17 00:00:00 2001 From: Deep Shah Date: Fri, 1 Nov 2019 13:20:23 +0530 Subject: [PATCH 1/3] =?UTF-8?q?In=20case=20of=20iOS=209.3.5=20when=20we=20?= =?UTF-8?q?show=20a=20web=20view=20and=20deallocate=20the=20layer=20it=20i?= =?UTF-8?q?s=20trying=20to=20release=20memory=20associated=20with=20WKWebV?= =?UTF-8?q?iew=20instance,=20but=20it=20hadn=E2=80=99t=20retained=20it=20i?= =?UTF-8?q?n=20the=20first=20place.=20This=20results=20in=20a=20crash.=20T?= =?UTF-8?q?his=20commit=20fixes=20that=20crash.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cocos/ui/UIWebViewImpl-ios.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/ui/UIWebViewImpl-ios.mm b/cocos/ui/UIWebViewImpl-ios.mm index 93d02f36e26a..72c69e1d080b 100644 --- a/cocos/ui/UIWebViewImpl-ios.mm +++ b/cocos/ui/UIWebViewImpl-ios.mm @@ -124,7 +124,7 @@ - (void)dealloc { - (void)setupWebView { if (!self.wkWebView) { - self.wkWebView = [[[WKWebView alloc] init] autorelease]; + self.wkWebView = [[[[WKWebView alloc] init] autorelease] retain]; self.wkWebView.UIDelegate = self; self.wkWebView.navigationDelegate = self; } From a350e7dad59cf29075b2e156eca397ea16ba7b24 Mon Sep 17 00:00:00 2001 From: Deep Shah Date: Tue, 12 Nov 2019 11:21:48 +0530 Subject: [PATCH 2/3] Removing the autorelease and retain parts from the WKWebView instantiation. --- cocos/ui/UIWebViewImpl-ios.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/ui/UIWebViewImpl-ios.mm b/cocos/ui/UIWebViewImpl-ios.mm index 72c69e1d080b..1cfff868e687 100644 --- a/cocos/ui/UIWebViewImpl-ios.mm +++ b/cocos/ui/UIWebViewImpl-ios.mm @@ -124,7 +124,7 @@ - (void)dealloc { - (void)setupWebView { if (!self.wkWebView) { - self.wkWebView = [[[[WKWebView alloc] init] autorelease] retain]; + self.wkWebView = [[WKWebView alloc] init]; self.wkWebView.UIDelegate = self; self.wkWebView.navigationDelegate = self; } From ce765aa729db1f22073915a6a04da281352471a3 Mon Sep 17 00:00:00 2001 From: Deep Shah Date: Thu, 14 Nov 2019 10:16:11 +0530 Subject: [PATCH 3/3] Changes so that we can remove the retain from the property declaration and depend only on manual retain and release of memory --- cocos/ui/UIWebViewImpl-ios.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/ui/UIWebViewImpl-ios.mm b/cocos/ui/UIWebViewImpl-ios.mm index 1cfff868e687..a41b1c79c3e1 100644 --- a/cocos/ui/UIWebViewImpl-ios.mm +++ b/cocos/ui/UIWebViewImpl-ios.mm @@ -88,7 +88,7 @@ - (void)setScalesPageToFit:(const bool)scalesPageToFit; @interface UIWebViewWrapper () -@property(nonatomic, retain) WKWebView *wkWebView; +@property(nonatomic) WKWebView *wkWebView; @property(nonatomic, copy) NSString *jsScheme; @end