Bug 240563 - Reflection for FrozenArray<Element> caching invariant
Summary: Reflection for FrozenArray<Element> caching invariant
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
Keywords: InRadar
Depends on:
Blocks: 196843
  Show dependency treegraph
Reported: 2022-05-18 00:18 PDT by Manuel Rego Casasnovas
Modified: 2022-06-02 14:45 PDT (History)
3 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Manuel Rego Casasnovas 2022-05-18 00:18:50 PDT
In bug #239853 we implemented reflection for FrozenArray<Element> attributes following the spec text at:

However the implementation doesn't match one of the things in the spec:
> This extra caching layer is necessary to preserve the invariant that element.reflectedElements === element.reflectedElements.

We don't have an extra caching layer so we can return the very same array in this case. The contents of the arrays are the same but the previous condition is false.

I'm not really sure how we could implemented that, as we're storing the "explicitly set attr-elements" using "HashMap<QualifiedName, Vector<WeakPtr<Element>>>" but Element::getElementsArrayAttribute() returns "Vector<RefPtr<Element>>". I'm not sure if we can cache the latter somehow without causing memory leaks.

Domenic suggested that ObservableArray could fix this issue (see https://github.com/web-platform-tests/wpt/pull/34095#discussion_r875333836), but we don't have support yet (bug #238281).

Any advice about how we can solve this issue? Thanks!
Comment 1 Manuel Rego Casasnovas 2022-05-19 12:40:35 PDT
cdumez@ suggested to use JSValueInWrappedObject to fix this issue. I'll give that a try. Thanks.
Comment 2 Manuel Rego Casasnovas 2022-05-24 22:52:38 PDT
Pull request with the patch: https://github.com/WebKit/WebKit/pull/974
Comment 3 Radar WebKit Bug Importer 2022-05-25 00:19:13 PDT
Comment 4 EWS 2022-06-02 14:45:53 PDT
Committed r295148 (251237@main): <https://commits.webkit.org/251237@main>

Reviewed commits have been landed. Closing PR #1166 and removing active labels.