Bug 185324 - Activate ARC for libwebrtc Objective C files
Summary: Activate ARC for libwebrtc Objective C files
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebRTC (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-05-04 14:09 PDT by youenn fablet
Modified: 2018-05-07 14:58 PDT (History)
8 users (show)

See Also:


Attachments
Patch (15.26 KB, patch)
2018-05-04 14:13 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (15.84 KB, patch)
2018-05-04 15:02 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (15.23 KB, patch)
2018-05-07 13:37 PDT, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description youenn fablet 2018-05-04 14:09:58 PDT
Activate ARC for libwebrtc Objective C files
Comment 1 youenn fablet 2018-05-04 14:13:17 PDT
Created attachment 339594 [details]
Patch
Comment 2 youenn fablet 2018-05-04 15:02:49 PDT
Created attachment 339600 [details]
Patch
Comment 3 Radar WebKit Bug Importer 2018-05-07 11:53:28 PDT
<rdar://problem/40031043>
Comment 4 David Kilzer (:ddkilzer) 2018-05-07 12:55:10 PDT
Comment on attachment 339600 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=339600&action=review

Okay, after reviewing all of this, I suggest you just back out the -fobjc-arc changes to libwebrtc.xcodeproj/project.pbxproj and simply change Source/ThirdParty/libwebrtc/Configurations/libwebrtc.xcconfig instead:

 DYLIB_INSTALL_NAME_BASE_WK_RELOCATABLE_FRAMEWORKS_ = $(DYLIB_INSTALL_NAME_BASE);
 DYLIB_INSTALL_NAME_BASE_WK_RELOCATABLE_FRAMEWORKS_YES = @loader_path/../../../;
 
+CLANG_ENABLE_OBJC_ARC = YES;
+
 CLANG_WARN_BOOL_CONVERSION = YES;
 CLANG_WARN_ENUM_CONVERSION = YES;
 CLANG_WARN_INT_CONVERSION = YES;

Keep the rest of the changes to the source code; I don't think you'll need to change anything else to enable ARC.

> Source/ThirdParty/libwebrtc/ChangeLog:24
> +        * libwebrtc.xcodeproj/project.pbxproj:

These files also need -fobjc-arc under the Source/webrtc/sdk directory:

NSString+StdString.mm
- Fix leak in -[NSString(StdString) stringForString:(const std::string&)].
RTCUIApplicationStatusObserver.m
- The __weak modifier won't do what you think it should without it.
UIDevice+RTCDevice.mm
- Fix leak in +[UIDevice(RTCDevice) machineName].

RTCI420Buffer.mm
- Consistency for Objective-C++ files under sdk/objc/Framework/Classes/Video/ (in case a future merge introduces a real -fobjc-arc requirement).

This Objective-C++ code in sdk/WebKit doesn't need -fobjc-arc, although it should probably have -fobc-arc added in case the upstream code changes in the future:
decoder.mm
encoder.mm
encoder_vcp.mm

These files don't require -fobjc-arc, but won't hurt to enable it under Source/webrtc/rtc_base (in case future upstream changes require it):

logging_mac.mm
noop.mm
thread_darwin.mm

One of these three files in Source/webrtc/modules/audio_device/ios requires -fobjc-arc (the others don't now, but might need it with future upstream changes):
audio_device_ios.mm
- Fix leak in RTCAudioSessionDelegateAdapter when AudioDeviceIOS is deallocated.
audio_device_not_implemented_ios.mm
- Not needed.
voice_processing_audio_unit.mm
- Not needed.
Comment 5 David Kilzer (:ddkilzer) 2018-05-07 12:56:11 PDT
Comment on attachment 339600 [details]
Patch

So r=me if you back out the changes to libwebrtc.xcodeproj/project.pbxproj and just change Source/ThirdParty/libwebrtc/Configurations/libwebrtc.xcconfig to enable ARC for all Objective-C source instead.
Comment 6 youenn fablet 2018-05-07 13:20:12 PDT
(In reply to David Kilzer (:ddkilzer) from comment #5)
> Comment on attachment 339600 [details]
> Patch
> 
> So r=me if you back out the changes to libwebrtc.xcodeproj/project.pbxproj
> and just change
> Source/ThirdParty/libwebrtc/Configurations/libwebrtc.xcconfig to enable ARC
> for all Objective-C source instead.

Thanks for the review!
I will try enabling ARC for all source code.

FWIW, decoder.mm, encoder.mm and encoder_vcp.mm do not need arc, these are the legacy non ARC codecs and are no longer in upstreamed libwebrtc tree.
I will update the project to no longer compile these.
Comment 7 youenn fablet 2018-05-07 13:37:57 PDT
Created attachment 339746 [details]
Patch
Comment 8 David Kilzer (:ddkilzer) 2018-05-07 14:53:52 PDT
Comment on attachment 339746 [details]
Patch

r=me if this passes EWS.
Comment 9 WebKit Commit Bot 2018-05-07 14:58:06 PDT
Comment on attachment 339746 [details]
Patch

Clearing flags on attachment: 339746

Committed r231459: <https://trac.webkit.org/changeset/231459>
Comment 10 WebKit Commit Bot 2018-05-07 14:58:07 PDT
All reviewed patches have been landed.  Closing bug.