Bug 221779 - Review usage of adoptNS()
Summary: Review usage of adoptNS()
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-02-11 14:06 PST by Chris Dumez
Modified: 2021-02-11 16:49 PST (History)
11 users (show)

See Also:


Attachments
Patch (20.77 KB, patch)
2021-02-11 14:08 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2021-02-11 14:06:44 PST
Review usage of adoptNS():
1. Make sure we call adoptNS() as soon as we allocate the object instead of doing it later on, as this is less error-prone
2. Fix cases where we called adoptNS() but really should have retained instead of adopting
Comment 1 Chris Dumez 2021-02-11 14:08:14 PST
Created attachment 420042 [details]
Patch
Comment 2 Alex Christensen 2021-02-11 14:14:14 PST
Comment on attachment 420042 [details]
Patch

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

> Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:510
>          [webAnimationDelegate setOwner:this];

If you use [m_delegate setOwner:this] instead, this can only be two lines.
Comment 3 Chris Dumez 2021-02-11 14:16:37 PST
Comment on attachment 420042 [details]
Patch

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

>> Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:510
>>          [webAnimationDelegate setOwner:this];
> 
> If you use [m_delegate setOwner:this] instead, this can only be two lines.

The issue is that the type of m_delegate is NSObject, not WebAnimationDelegate. Maybe that still works in ObjC?
Comment 4 Chris Dumez 2021-02-11 14:20:55 PST
(In reply to Chris Dumez from comment #3)
> Comment on attachment 420042 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=420042&action=review
> 
> >> Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:510
> >>          [webAnimationDelegate setOwner:this];
> > 
> > If you use [m_delegate setOwner:this] instead, this can only be two lines.
> 
> The issue is that the type of m_delegate is NSObject, not
> WebAnimationDelegate. Maybe that still works in ObjC?

As I thought, this does not work:
./platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:510:21: error: 'NSObject' may not respond to 'setOwner:' [-Werror]
Comment 5 EWS 2021-02-11 16:48:52 PST
Committed r272760: <https://commits.webkit.org/r272760>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 420042 [details].
Comment 6 Radar WebKit Bug Importer 2021-02-11 16:49:14 PST
<rdar://problem/74256841>