Reduce explicit usage of [objC autorelease] in WebKit by using RetainPtr<>.
Created attachment 420390 [details] Patch
Created attachment 420404 [details] Patch
Created attachment 420513 [details] Patch
This patch modifies the inspector protocol generator. Please ensure that you have rebaselined any generator test results (i.e., by running `Tools/Scripts/run-inspector-generator-tests --reset-results`)
Comment on attachment 420513 [details] Patch r=me -- note the style bot comment about test results
Created attachment 420530 [details] Patch
Committed r272936: <https://commits.webkit.org/r272936> All reviewed patches have been landed. Closing bug and clearing flags on attachment 420530 [details].
<rdar://problem/74410900>
Comment on attachment 420530 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=420530&action=review Looking back at this to see where we have opportunity to use a little less autorelease. > Source/JavaScriptCore/API/JSContext.mm:71 > + return [self initWithVirtualMachine:adoptNS([[JSVirtualMachine alloc] init]).autorelease()]; get() > Source/JavaScriptCore/API/JSWrapperMap.mm:638 > + return m_classMap.get()[(id)cls] = adoptNS([[JSObjCClassInfo alloc] initForClass:cls]).autorelease(); get() > Source/JavaScriptCore/inspector/scripts/codegen/objc_generator.py:408 > + return 'adoptNS([[%s alloc] initWithJSONObject:%s]).autorelease()' % (objc_class, var_name) This should be changed to use RetainPtr instead of autorelease. > Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:2550 > + object = adoptNS([[NSMutableAttributedString alloc] initWithString:[NSString stringWithCharacters:&attachmentChar length:1] attributes:@{ UIAccessibilityTokenAttachment : object }]).autorelease(); Seems like we could use RetainPtr instead of autorelease here. > Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm:131 > + @"WebResourceHandler": adoptNS([WebArchiveResourceWebResourceHandler new]).autorelease(), get() > Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:923 > + resourceLoader.URLSession = (NSURLSession *)adoptNS([[WebCoreNSURLSession alloc] initWithResourceLoader:*mediaResourceLoader delegate:resourceLoader.URLSessionDataDelegate delegateQueue:resourceLoader.URLSessionDataDelegateQueue]).autorelease(); get() > Source/WebCore/platform/ios/WebAVPlayerController.mm:72 > + self.playerControllerProxy = adoptNS([allocAVPlayerControllerInstance() init]).autorelease(); get() > Source/WebCore/platform/ios/wak/WAKView.mm:241 > + [adoptNS([subviewReferences copy]).autorelease() makeObjectsPerformSelector:@selector(removeFromSuperview)]; get() > Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm:666 > + request = mutableRequest.autorelease(); I think we can use a local RetainPtr instead. > Source/WebCore/platform/network/mac/ResourceHandleMac.mm:176 > + nsRequest = copyRequestWithStorageSession(d->m_storageSession.get(), nsRequest).autorelease(); I think we can use a local RetainPtr instead. > Source/WebCore/platform/network/mac/ResourceHandleMac.mm:183 > + NSMutableDictionary *streamProperties = streamPropertiesFromClient ? adoptNS([streamPropertiesFromClient mutableCopy]).autorelease() : [NSMutableDictionary dictionary]; I think we can use RetainPtr instead. > Source/WebKit/UIProcess/API/Cocoa/NSAttributedString.mm:313 > + finish(retainPtr(attributedString).autorelease(), retainPtr(documentAttributes).autorelease(), nil); I don’t think we need retain/autorelease here at all. > Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:1219 > + completionHandler(adoptNS([[WKFindResult alloc] _initWithMatchFound:NO]).autorelease()); get() > Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:1224 > + handler(adoptNS([[WKFindResult alloc] _initWithMatchFound:found]).autorelease()); get() > Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:1713 > + completionHandler(node.autorelease()); I don’t think we need retain/autorelease at all here. > Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:2580 > + handler(retainPtr(attributedString.string.get()).autorelease(), retainPtr(attributedString.documentAttributes.get()).autorelease(), nil); I don’t think we need retain/autorelease here at all. > Source/WebKit/UIProcess/API/Cocoa/_WKAutomationSession.mm:44 > + return [self initWithConfiguration:adoptNS([[_WKAutomationSessionConfiguration alloc] init]).autorelease()]; get() > Source/WebKit/UIProcess/API/Cocoa/_WKInspector.mm:191 > + capturedBlock(nil, retainPtr(wrapper(API::InspectorExtension::create(protectedExtensionID.get(), protectedSelf->_inspector->extensionController()))).autorelease()); I don’t think we need retain/autorelease at all here. > Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm:171 > + capturedBlock(nil, retainPtr(wrapper(API::InspectorExtension::create(protectedExtensionID.get(), protectedSelf->m_remoteInspectorProxy->extensionController()))).autorelease()); I don’t think we need retain/autorelease at all here. > Source/WebKit/UIProcess/API/Cocoa/_WKUserContentExtensionStore.mm:75 > + completionHandler(contentFilter.autorelease(), toUserContentRuleListStoreError(error)); get() > Source/WebKit/UIProcess/API/Cocoa/_WKUserContentExtensionStore.mm:83 > + completionHandler(contentFilter.autorelease(), toUserContentRuleListStoreError(error)); get() > Source/WebKit/UIProcess/Automation/ios/WebAutomationSessionIOS.mm:135 > + [eventsToBeSent addObject:adoptNS([[::WebEvent alloc] initWithKeyEventType:WebEventKeyDown timeStamp:CFAbsoluteTimeGetCurrent() characters:characters charactersIgnoringModifiers:unmodifiedCharacters modifiers:m_currentModifiers isRepeating:NO withFlags:inputFlags withInputManagerHint:nil keyCode:keyCode isTabKey:isTabKey]).autorelease()]; get() > Source/WebKit/UIProcess/Automation/ios/WebAutomationSessionIOS.mm:141 > + [eventsToBeSent addObject:adoptNS([[::WebEvent alloc] initWithKeyEventType:WebEventKeyUp timeStamp:CFAbsoluteTimeGetCurrent() characters:characters charactersIgnoringModifiers:unmodifiedCharacters modifiers:m_currentModifiers isRepeating:NO withFlags:inputFlags withInputManagerHint:nil keyCode:keyCode isTabKey:isTabKey]).autorelease()]; get() > Source/WebKit/UIProcess/Automation/ios/WebAutomationSessionIOS.mm:146 > + [eventsToBeSent addObject:adoptNS([[::WebEvent alloc] initWithKeyEventType:WebEventKeyDown timeStamp:CFAbsoluteTimeGetCurrent() characters:characters charactersIgnoringModifiers:unmodifiedCharacters modifiers:m_currentModifiers isRepeating:NO withFlags:inputFlags withInputManagerHint:nil keyCode:keyCode isTabKey:isTabKey]).autorelease()]; get() > Source/WebKit/UIProcess/Automation/ios/WebAutomationSessionIOS.mm:147 > + [eventsToBeSent addObject:adoptNS([[::WebEvent alloc] initWithKeyEventType:WebEventKeyUp timeStamp:CFAbsoluteTimeGetCurrent() characters:characters charactersIgnoringModifiers:unmodifiedCharacters modifiers:m_currentModifiers isRepeating:NO withFlags:inputFlags withInputManagerHint:nil keyCode:keyCode isTabKey:isTabKey]).autorelease()]; get() > Source/WebKit/UIProcess/Cocoa/WKContactPicker.mm:294 > + [contacts addObject:contact.autorelease()]; get()
Reopening to attach new patch.
Created attachment 420872 [details] Follow-up
Created attachment 420874 [details] Follow up
Committed r273128: <https://commits.webkit.org/r273128> All reviewed patches have been landed. Closing bug and clearing flags on attachment 420874 [details].