RESOLVED FIXED 200436
navigator.geolocation wrapper should not become GC-collectable once its frame is detached
https://bugs.webkit.org/show_bug.cgi?id=200436
Summary navigator.geolocation wrapper should not become GC-collectable once its frame...
Chris Dumez
Reported 2019-08-05 08:34:41 PDT
navigator.geolocation wrapper should not become GC-collectable once its frame is detached, given that it can outlive the frame.
Attachments
Patch (26.20 KB, patch)
2019-08-05 09:58 PDT, Chris Dumez
no flags
Patch (26.31 KB, patch)
2019-08-05 10:07 PDT, Chris Dumez
no flags
Patch (26.94 KB, patch)
2019-08-05 10:15 PDT, Chris Dumez
no flags
Archive of layout-test-results from ews103 for mac-highsierra (3.20 MB, application/zip)
2019-08-05 11:16 PDT, EWS Watchlist
no flags
Patch (28.00 KB, patch)
2019-08-05 11:53 PDT, Chris Dumez
no flags
Patch (28.14 KB, patch)
2019-08-05 11:55 PDT, Chris Dumez
no flags
Patch (29.87 KB, patch)
2019-08-05 14:28 PDT, Chris Dumez
no flags
Chris Dumez
Comment 1 2019-08-05 09:58:28 PDT
EWS Watchlist
Comment 2 2019-08-05 10:00:08 PDT
Attachment 375530 [details] did not pass style-queue: ERROR: Source/WebCore/Modules/geolocation/Geolocation.h:164: enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums. [readability/enum_casing] [4] ERROR: Source/WebCore/Modules/geolocation/Geolocation.h:165: enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums. [readability/enum_casing] [4] ERROR: Source/WebCore/Modules/geolocation/Geolocation.h:166: enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums. [readability/enum_casing] [4] Total errors found: 3 in 23 files If any of these errors are false positives, please file a bug against check-webkit-style.
Chris Dumez
Comment 3 2019-08-05 10:07:54 PDT
EWS Watchlist
Comment 4 2019-08-05 10:10:04 PDT
Attachment 375531 [details] did not pass style-queue: ERROR: Source/WebCore/Modules/geolocation/Geolocation.h:164: enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums. [readability/enum_casing] [4] ERROR: Source/WebCore/Modules/geolocation/Geolocation.h:165: enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums. [readability/enum_casing] [4] ERROR: Source/WebCore/Modules/geolocation/Geolocation.h:166: enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums. [readability/enum_casing] [4] Total errors found: 3 in 23 files If any of these errors are false positives, please file a bug against check-webkit-style.
Chris Dumez
Comment 5 2019-08-05 10:15:45 PDT
EWS Watchlist
Comment 6 2019-08-05 10:17:06 PDT
Attachment 375533 [details] did not pass style-queue: ERROR: Source/WebCore/Modules/geolocation/Geolocation.h:164: enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums. [readability/enum_casing] [4] ERROR: Source/WebCore/Modules/geolocation/Geolocation.h:165: enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums. [readability/enum_casing] [4] ERROR: Source/WebCore/Modules/geolocation/Geolocation.h:166: enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums. [readability/enum_casing] [4] Total errors found: 3 in 24 files If any of these errors are false positives, please file a bug against check-webkit-style.
EWS Watchlist
Comment 7 2019-08-05 11:16:20 PDT
Comment on attachment 375533 [details] Patch Attachment 375533 [details] did not pass mac-ews (mac): Output: https://webkit-queues.webkit.org/results/12864090 New failing tests: fast/dom/navigator-property-gc-after-frame-detach.html
EWS Watchlist
Comment 8 2019-08-05 11:16:22 PDT
Created attachment 375537 [details] Archive of layout-test-results from ews103 for mac-highsierra The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews103 Port: mac-highsierra Platform: Mac OS X 10.13.6
Chris Dumez
Comment 9 2019-08-05 11:53:45 PDT
Chris Dumez
Comment 10 2019-08-05 11:55:16 PDT
EWS Watchlist
Comment 11 2019-08-05 11:56:29 PDT
Attachment 375543 [details] did not pass style-queue: ERROR: Source/WebCore/Modules/geolocation/Geolocation.h:164: enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums. [readability/enum_casing] [4] ERROR: Source/WebCore/Modules/geolocation/Geolocation.h:165: enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums. [readability/enum_casing] [4] ERROR: Source/WebCore/Modules/geolocation/Geolocation.h:166: enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums. [readability/enum_casing] [4] Total errors found: 3 in 25 files If any of these errors are false positives, please file a bug against check-webkit-style.
Darin Adler
Comment 12 2019-08-05 13:31:55 PDT
Comment on attachment 375543 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=375543&action=review Looks great. > Source/WebCore/Modules/geolocation/Geolocation.h:77 > + WEBCORE_EXPORT Frame* frame() const; I guess there must be important clients of this function, but seems annoying that we have it. > Source/WebCore/Modules/geolocation/Geolocation.h:163 > + } m_allowGeolocation { Unknown }; Not sure you will agree, but I think this would read slightly better all on one line: enum { Unknown, InProgress, Yes, No } m_allowGeolocation { Unknown }; > Source/WebCore/Modules/geolocation/NavigatorGeolocation.cpp:76 > + m_geolocation = Geolocation::create(*m_navigator); Is this correct for the case where m_navigator is nullptr? I assume it can be null because it’s a WeakPtr. > Source/WebCore/bindings/js/JSNavigatorCustom.cpp:33 > + visitor.addOpaqueRoot(static_cast<NavigatorBase*>(&wrapped())); I wish there was a safer cast for upcasts rather than static_cast, which can also do other kinds of casting like downcasts. I also wish there was less void* danger here. If we passed &wrapped() without casting to NavigatorBase*, how would we know we had it wrong? > Source/WebCore/bindings/js/JSWorkerNavigatorCustom.cpp:33 > + visitor.addOpaqueRoot(static_cast<NavigatorBase*>(&wrapped())); Ditto. > Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:4686 > + $rootString = " auto* root = static_cast<NavigatorBase*>(WTF::getPtr(js${interfaceName}->wrapped().navigator()));\n"; Ditto. > Source/WebCore/plugins/DOMMimeTypeArray.h:43 > + Navigator* navigator() { return m_navigator.get(); } Inconsistent that the other getter functions are const, but not this. > Source/WebCore/plugins/DOMMimeTypeArray.h:44 > + Frame* frame() const { return m_navigator ? m_navigator->frame() : nullptr; } I assume we need these because there was a DOMWindowProperty::frame function. But since it’s not new I can’t see the call sites in this patch. Seems like it would be more elegant if we didn’t need these, but maybe if I saw the call sites I would understand why we do. > Source/WebCore/plugins/DOMPluginArray.h:47 > + Frame* frame() const { return m_navigator ? m_navigator->frame() : nullptr; } Ditto.
Darin Adler
Comment 13 2019-08-05 13:37:10 PDT
Comment on attachment 375543 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=375543&action=review >> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:4686 >> + $rootString = " auto* root = static_cast<NavigatorBase*>(WTF::getPtr(js${interfaceName}->wrapped().navigator()));\n"; > > Ditto. Since it’s a local variable we could write this without the static_cast: NavigatorBase* root = WTF::getPtr(js${interfaceName}->wrapped().navigator()); But not sure if overall that makes this better or worse.
Chris Dumez
Comment 14 2019-08-05 14:21:00 PDT
Comment on attachment 375543 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=375543&action=review >> Source/WebCore/Modules/geolocation/Geolocation.h:77 >> + WEBCORE_EXPORT Frame* frame() const; > > I guess there must be important clients of this function, but seems annoying that we have it. Yes, this one is actually used by WebKit2 or WebKitLegacy, which is why I had to export it. I will check what it is used for. >> Source/WebCore/Modules/geolocation/Geolocation.h:163 >> + } m_allowGeolocation { Unknown }; > > Not sure you will agree, but I think this would read slightly better all on one line: > > enum { Unknown, InProgress, Yes, No } m_allowGeolocation { Unknown }; Ok. >> Source/WebCore/Modules/geolocation/NavigatorGeolocation.cpp:76 >> + m_geolocation = Geolocation::create(*m_navigator); > > Is this correct for the case where m_navigator is nullptr? I assume it can be null because it’s a WeakPtr. It actually cannot be null, this is a NavigatorSupplement so it is owned by Navigator. I should not be using a WeakPtr in this class. >> Source/WebCore/bindings/js/JSNavigatorCustom.cpp:33 >> + visitor.addOpaqueRoot(static_cast<NavigatorBase*>(&wrapped())); > > I wish there was a safer cast for upcasts rather than static_cast, which can also do other kinds of casting like downcasts. I also wish there was less void* danger here. If we passed &wrapped() without casting to NavigatorBase*, how would we know we had it wrong? It is a bit error-prone yes, but my test would fail if we would get it wrong. >>> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:4686 >>> + $rootString = " auto* root = static_cast<NavigatorBase*>(WTF::getPtr(js${interfaceName}->wrapped().navigator()));\n"; >> >> Ditto. > > Since it’s a local variable we could write this without the static_cast: > > NavigatorBase* root = WTF::getPtr(js${interfaceName}->wrapped().navigator()); > > But not sure if overall that makes this better or worse. I like it, will switch. >> Source/WebCore/plugins/DOMMimeTypeArray.h:44 >> + Frame* frame() const { return m_navigator ? m_navigator->frame() : nullptr; } > > I assume we need these because there was a DOMWindowProperty::frame function. But since it’s not new I can’t see the call sites in this patch. Seems like it would be more elegant if we didn’t need these, but maybe if I saw the call sites I would understand why we do. Those frame() getters on DOMMimeTypeArray and DOMPluginArray are only used by the internal implementation iirc (for early returns). At the very least, I can likely make them private. >> Source/WebCore/plugins/DOMPluginArray.h:47 >> + Frame* frame() const { return m_navigator ? m_navigator->frame() : nullptr; } > > Ditto. See comment above.
Chris Dumez
Comment 15 2019-08-05 14:27:35 PDT
Comment on attachment 375543 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=375543&action=review >>> Source/WebCore/Modules/geolocation/Geolocation.h:77 >>> + WEBCORE_EXPORT Frame* frame() const; >> >> I guess there must be important clients of this function, but seems annoying that we have it. > > Yes, this one is actually used by WebKit2 or WebKitLegacy, which is why I had to export it. I will check what it is used for. /Volumes/Data/WebKit/OpenSource/Source/WebKitLegacy/mac/WebCoreSupport/WebGeolocationClient.mm:114:32: error: 'frame' is a private member of 'WebCore::Geolocation' Frame *frame = geolocation.frame(); if (!frame) { geolocation.setIsAllowed(false); return; }
Chris Dumez
Comment 16 2019-08-05 14:28:15 PDT
WebKit Commit Bot
Comment 17 2019-08-05 16:00:32 PDT
Comment on attachment 375556 [details] Patch Clearing flags on attachment: 375556 Committed r248276: <https://trac.webkit.org/changeset/248276>
WebKit Commit Bot
Comment 18 2019-08-05 16:00:34 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 19 2019-08-05 16:01:20 PDT
Alexey Proskuryakov
Comment 20 2019-08-06 10:55:04 PDT
Comment on attachment 375556 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=375556&action=review > LayoutTests/platform/wk2/TestExpectations:-163 > -webkit.org/b/141122 editing/selection/programmatic-selection-on-mac-is-directionless.html [ Pass Failure ] This change landed accidentally, could you please undo it?
Chris Dumez
Comment 21 2019-08-06 10:56:07 PDT
(In reply to Alexey Proskuryakov from comment #20) > Comment on attachment 375556 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=375556&action=review > > > LayoutTests/platform/wk2/TestExpectations:-163 > > -webkit.org/b/141122 editing/selection/programmatic-selection-on-mac-is-directionless.html [ Pass Failure ] > > This change landed accidentally, could you please undo it? Ah.. That will teach me to work on 2 things at the same time. Will fix now.
Chris Dumez
Comment 22 2019-08-06 10:57:58 PDT
Darin Adler
Comment 23 2019-08-06 11:41:40 PDT
(In reply to Chris Dumez from comment #15) > /Volumes/Data/WebKit/OpenSource/Source/WebKitLegacy/mac/WebCoreSupport/ > WebGeolocationClient.mm:114:32: error: 'frame' is a private member of > 'WebCore::Geolocation' So we need to keep this as long as we want to support the webView:decidePolicyForGeolocationRequestFromOrigin:frame:listener: delegate method on the iOS platform family. As an aside, I think we could consider dropping support for that at some point as part of cutting down the complexity of WebKitLegacy.
Note You need to log in before you can comment on or make changes to this bug.