Bug 223635

Summary: Implement cachedPropertyValue for WebXR [SameObject] attributes
Product: WebKit Reporter: Imanol Fernandez <ifernandez>
Component: WebXRAssignee: Imanol Fernandez <ifernandez>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, esprehn+autocc, ews-watchlist, kondapallykalyan, sam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 208988    
Attachments:
Description Flags
Patch
none
Patch
none
Patch for landing none

Imanol Fernandez
Reported 2021-03-23 07:53:46 PDT
[SameObject] is not currently implemented in WebKit. We need to implement custom getters.
Attachments
Patch (21.94 KB, patch)
2021-03-23 08:30 PDT, Imanol Fernandez
no flags
Patch (23.00 KB, patch)
2021-03-23 09:25 PDT, Imanol Fernandez
no flags
Patch for landing (20.06 KB, patch)
2021-03-26 09:13 PDT, Imanol Fernandez
no flags
Imanol Fernandez
Comment 1 2021-03-23 08:30:14 PDT
Chris Dumez
Comment 2 2021-03-23 08:46:51 PDT
Comment on attachment 424019 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=424019&action=review > Source/WebCore/Modules/webxr/WebXRRigidTransform.idl:38 > + [CustomGetter] readonly attribute Float32Array matrix; Same issue as below. > Source/WebCore/Modules/webxr/WebXRViewerPose.idl:35 > + [CustomGetter, SameObject] readonly attribute FrozenArray<WebXRView> views; You also need [JSCustomMarkFunction] on the interface and custom bindings code for visitAdditionalChildren() which visits cachedViews() on the impl object.
Chris Dumez
Comment 3 2021-03-23 08:53:32 PDT
Comment on attachment 424019 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=424019&action=review > Source/WebCore/Modules/webxr/WebXRRigidTransform.idl:36 > [SameObject] readonly attribute DOMPointReadOnly position; Note that SameObject does nothing besides documenting. You don't have to do it in this change since it does not seem needed for WPT tests. That said, I suggest you add a new test that does: transfer.position.foo = 1; gc(); setTimeout(() => { gc(); shouldBe("transfer.position.foo", "1"); }, 0); I suspect this will fail because we don't guarantee we are returning the same object after GC. You can see how JSDOMQuad::visitAdditionalChildren() visits its internal DOMPoint attributes to keep them alive. You'll likely need to do the exact same thing as JSDOMQuad::visitAdditionalChildren() for position & orientation attributes here. The inverse attribute will likely be an issue too.
Imanol Fernandez
Comment 4 2021-03-23 09:25:59 PDT
Created attachment 424025 [details] Patch Add JSCustomMarkFunction
Imanol Fernandez
Comment 5 2021-03-23 09:27:25 PDT
(In reply to Chris Dumez from comment #3) > Comment on attachment 424019 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=424019&action=review > > > Source/WebCore/Modules/webxr/WebXRRigidTransform.idl:36 > > [SameObject] readonly attribute DOMPointReadOnly position; > > Note that SameObject does nothing besides documenting. You don't have to do > it in this change since it does not seem needed for WPT tests. That said, I > suggest you add a new test that does: > transfer.position.foo = 1; > gc(); > setTimeout(() => { > gc(); > shouldBe("transfer.position.foo", "1"); > }, 0); > > I suspect this will fail because we don't guarantee we are returning the > same object after GC. You can see how JSDOMQuad::visitAdditionalChildren() > visits its internal DOMPoint attributes to keep them alive. You'll likely > need to do the exact same thing as JSDOMQuad::visitAdditionalChildren() for > position & orientation attributes here. The inverse attribute will likely be > an issue too. Thanks for the info. I'll test that and add the additional visitAdditionalChildren and test if required
Sam Weinig
Comment 6 2021-03-23 10:03:58 PDT
(In reply to Chris Dumez from comment #2) > Comment on attachment 424019 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=424019&action=review > > > Source/WebCore/Modules/webxr/WebXRRigidTransform.idl:38 > > + [CustomGetter] readonly attribute Float32Array matrix; > > Same issue as below. > > > Source/WebCore/Modules/webxr/WebXRViewerPose.idl:35 > > + [CustomGetter, SameObject] readonly attribute FrozenArray<WebXRView> views; > > You also need [JSCustomMarkFunction] on the interface and custom bindings > code for visitAdditionalChildren() which visits cachedViews() on the impl > object. Could something like: [CachedAttribute, SameObject] readonly attribute FrozenArray<WebXRView> views; be used instead for a case like this (it's been a while since I looked into this, so I can never quire remember).
Chris Dumez
Comment 7 2021-03-23 15:27:57 PDT
Comment on attachment 424025 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=424025&action=review > Source/WebCore/Modules/webxr/WebXRViewerPose.idl:36 > + [CustomGetter, SameObject] readonly attribute FrozenArray<WebXRView> views; I suggest you try [CachedAttribute, SameObject] for this FrozenArray, as Sam suggested. If it works, then you won't need custom bindings for this one, which would be nice.
Imanol Fernandez
Comment 8 2021-03-26 09:10:23 PDT
Comment on attachment 424025 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=424025&action=review >> Source/WebCore/Modules/webxr/WebXRViewerPose.idl:36 >> + [CustomGetter, SameObject] readonly attribute FrozenArray<WebXRView> views; > > I suggest you try [CachedAttribute, SameObject] for this FrozenArray, as Sam suggested. If it works, then you won't need custom bindings for this one, which would be nice. It works, thanks for the suggestion
Imanol Fernandez
Comment 9 2021-03-26 09:13:38 PDT
Created attachment 424363 [details] Patch for landing
EWS
Comment 10 2021-03-26 09:41:33 PDT
Committed r275102: <https://commits.webkit.org/r275102> All reviewed patches have been landed. Closing bug and clearing flags on attachment 424363 [details].
Radar WebKit Bug Importer
Comment 11 2021-03-26 09:42:15 PDT
Note You need to log in before you can comment on or make changes to this bug.