Repository navigation
Freeze IntersectionObserver threshold configuration (#60310) - #60310
Merged
Merged
Conversation
|
@rubennorte has exported this pull request. If you are a Meta employee, you can view the originating Diff in D134237377. |
Visual regressionNo visual differences at |
javache
approved these changes
Nov 26, 2026
javache
left a comment
Contributor
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Nov 26, 2026
Summary: ## Context IntersectionObserver exposes normalized threshold arrays as read-only configuration, but a static read-only type does not prevent JavaScript callers from mutating the arrays at runtime. ## Changes Freeze normalized `thresholds` and `rnRootThresholds` arrays at construction without freezing caller-owned inputs. Add public cases for mutation rejection, input independence, and default/scalar/empty configurations. Native threshold lookup and supported threshold counts remain unchanged. Changelog: [General][Fixed] - Keep IntersectionObserver threshold arrays immutable Reviewed By: javache Differential Revision: D134237377
rubennorte
force-pushed
the
export-D134237377
branch
from
November 26, 2026 14:17
9463d09 to
930a8c1
Compare
Summary: ## Context Benchmarks should cover how IntersectionObserver is normally configured: one or two thresholds, with ten and one hundred as bounds. ## Changes Keep all public benchmark additions in this first, benchmark-only diff. Cover 1, 2, 10, and 100 thresholds, deep implicit/explicit roots, and target/root ratio reads. Parameterize callback-count assertions for the threshold count. No runtime implementation or API threshold-count limit is changed. ## Baseline benchmark results Optimized Fantom (native + Hermes bytecode), headless Linux, fixed CPU affinity. This benchmark-only baseline includes landed scrollMargin support, but no runtime changes from this stack. Values are median CPU time per complete invocation from the current run; setup/assertions are outside timed work. Scaling cases have 100 measured invocations and cover 1/2 thresholds plus 10/100 bounds. | Benchmark | Baseline CPU | | --- | --- | | `Read intersectionRatio 1000 times` | 5.105 ms | | `Read rnRootIntersectionRatio 1000 times` | 4.962 ms | | `Scroll 100 targets, depth 1, 1 thresholds, implicit root` | 7.238 ms | | `Scroll 100 targets, depth 1, 2 thresholds, implicit root` | 7.513 ms | | `Scroll 100 targets, depth 1, 10 thresholds, implicit root` | 8.560 ms | | `Scroll 100 targets, depth 1, 100 thresholds, implicit root` | 20.442 ms | | `Scroll 100 targets, depth 40, 1 thresholds, implicit root` | 38.032 ms | | `Scroll 100 targets, depth 40, 1 thresholds, explicit root` | 46.293 ms | Scrolling includes mounting and intersection computation, plus callbacks when thresholds are crossed. Ratio rows measure consumer reads, not notification dispatch. Changelog: [Internal] Reviewed By: javache Differential Revision: D134252378
Summary: ## Context IntersectionObserver exposes normalized threshold arrays as read-only configuration, but a static read-only type does not prevent JavaScript callers from mutating the arrays at runtime. ## Changes Freeze normalized `thresholds` and `rnRootThresholds` arrays at construction without freezing caller-owned inputs. Add public cases for mutation rejection, input independence, and default/scalar/empty configurations. Native threshold lookup and supported threshold counts remain unchanged. Changelog: [General][Fixed] - Keep IntersectionObserver threshold arrays immutable Reviewed By: javache Differential Revision: D134237377
rubennorte
force-pushed
the
export-D134237377
branch
from
November 26, 2026 14:22
930a8c1 to
1433a13
Compare
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Nov 26, 2026
Summary: ## Context IntersectionObserver exposes normalized threshold arrays as read-only configuration, but a static read-only type does not prevent JavaScript callers from mutating the arrays at runtime. ## Changes Freeze normalized `thresholds` and `rnRootThresholds` arrays at construction without freezing caller-owned inputs. Add public cases for mutation rejection, input independence, and default/scalar/empty configurations. Native threshold lookup and supported threshold counts remain unchanged. Changelog: [General][Fixed] - Keep IntersectionObserver threshold arrays immutable Reviewed By: javache Differential Revision: D134237377
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Nov 26, 2026
Summary: ## Context IntersectionObserver exposes normalized threshold arrays as read-only configuration, but a static read-only type does not prevent JavaScript callers from mutating the arrays at runtime. ## Changes Freeze normalized `thresholds` and `rnRootThresholds` arrays at construction without freezing caller-owned inputs. Add public cases for mutation rejection, input independence, and default/scalar/empty configurations. Native threshold lookup and supported threshold counts remain unchanged. Changelog: [General][Fixed] - Keep IntersectionObserver threshold arrays immutable Reviewed By: javache Differential Revision: D134237377
Collaborator
|
This pull request was successfully merged by @rubennorte in 35a784b When will my fix make it into a release? | How to file a pick request? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Context
IntersectionObserver exposes normalized threshold arrays as read-only configuration, but a static read-only type does not prevent JavaScript callers from mutating the arrays at runtime.
Changes
Freeze normalized
thresholdsandrnRootThresholdsarrays at construction without freezing caller-owned inputs. Add public cases for mutation rejection, input independence, and default/scalar/empty configurations. Native threshold lookup and supported threshold counts remain unchanged.Changelog:
[General][Fixed] - Keep IntersectionObserver threshold arrays immutable
Reviewed By: javache
Differential Revision: D134237377