Skip to content

Commit

Permalink
Fixing a crash in iOS 9.3.5 when we have a layer with WebView getting…
Browse files Browse the repository at this point in the history
… deallocated (cocos2d#20285)

* 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 <Deep>
  • Loading branch information
deepshah7 authored and minggo committed Nov 14, 2019
1 parent 6a53b31 commit 8b5513e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cocos/ui/UIWebView/UIWebViewImpl-ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ - (void)setScalesPageToFit:(const bool)scalesPageToFit;


@interface UIWebViewWrapper () <WKUIDelegate, WKNavigationDelegate>
@property(nonatomic, retain) WKWebView *wkWebView;
@property(nonatomic) WKWebView *wkWebView;

@property(nonatomic, copy) NSString *jsScheme;
@end
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 8b5513e

Please sign in to comment.