Bug 223635 - Implement cachedPropertyValue for WebXR [SameObject] attributes
Summary: Implement cachedPropertyValue for WebXR [SameObject] attributes
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebXR (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Imanol Fernandez
URL:
Keywords: InRadar
Depends on:
Blocks: 208988
  Show dependency treegraph
 
Reported: 2021-03-23 07:53 PDT by Imanol Fernandez
Modified: 2021-03-26 09:42 PDT (History)
6 users (show)

See Also:


Attachments
Patch (21.94 KB, patch)
2021-03-23 08:30 PDT, Imanol Fernandez
no flags Details | Formatted Diff | Diff
Patch (23.00 KB, patch)
2021-03-23 09:25 PDT, Imanol Fernandez
no flags Details | Formatted Diff | Diff
Patch for landing (20.06 KB, patch)
2021-03-26 09:13 PDT, Imanol Fernandez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Imanol Fernandez 2021-03-23 07:53:46 PDT
[SameObject] is not currently implemented in WebKit. We need to implement custom getters.
Comment 1 Imanol Fernandez 2021-03-23 08:30:14 PDT
Created attachment 424019 [details]
Patch
Comment 2 Chris Dumez 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.
Comment 3 Chris Dumez 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.
Comment 4 Imanol Fernandez 2021-03-23 09:25:59 PDT
Created attachment 424025 [details]
Patch

Add JSCustomMarkFunction
Comment 5 Imanol Fernandez 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
Comment 6 Sam Weinig 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).
Comment 7 Chris Dumez 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.
Comment 8 Imanol Fernandez 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
Comment 9 Imanol Fernandez 2021-03-26 09:13:38 PDT
Created attachment 424363 [details]
Patch for landing
Comment 10 EWS 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].
Comment 11 Radar WebKit Bug Importer 2021-03-26 09:42:15 PDT
<rdar://problem/75889305>