Skip to content

[ListView] Make LVDS.getSectionLengths() be indexed by section ID - #100

Closed
ide wants to merge 1 commit into
react:masterfrom
ide:section-lengths
Closed

ide wants to merge 1 commit into
react:masterfrom
ide:section-lengths

Conversation

@ide

@ide ide commented Feb 25, 2015

Copy link
Copy Markdown
Contributor

Currently ListViewDataSource.getSectionLengths() returns an array of section lengths, where the nth element of the array is the number of rows in the nth section. There is a tiny bit of an API mismatch since elsewhere section IDs, which are strings, are primarily used. This diff changes getSectionLengths to return an object whose keys are section IDs and values are the number of rows in each respective section.

Before: [10, 20, 30]
After: {firstSection: 10, secondSection: 20, thirdSection: 30}

Currently ListViewDataSource.getSectionLengths() returns an array of section lengths, where the nth element of the array is the number of rows in the nth section. There is a tiny bit of an API mismatch since elsewhere section IDs, which are strings, are primarily used. This diff changes getSectionLengths to return an object whose keys are section IDs and values are the number of rows in each respective section.

Before: `[10, 20, 30]`
After: `{firstSection: 10, secondSection: 20, thirdSection: 30}`
@ide

ide commented Feb 25, 2015

Copy link
Copy Markdown
Contributor Author

Scratch this -- I think working with the numeric indices is more appropriate at this level of abstraction.

@ide ide closed this Feb 25, 2015
react-one pushed a commit to react-one/react-native that referenced this pull request Sep 24, 2021
javache added a commit to javache/react-native that referenced this pull request Oct 28, 2024
…eact#46702)

Summary:
Pull Request resolved: react#46702

In react#44188, we've started combining multiple transactions in a single transaction, to meet React's atomicity requirements, while also dealing with the constraints of Android's Fabric implementation.

This revealed a bug where in some scenarios (especially when using transitions), a node may be deleted and created during the same transaction. The current implementation of FabricMountingManager assumes it can safely reorder some operations, which it does to optimize the size of IntBufferBatch mount items. This is however incorrect and unsafe when multiple transactions are merged.

**Example:**

Differentiator output:

```
# Transaction 1
Remove react#100 from react#11
Delete react#100

# Transaction 2
Create react#100
Insert react#100 into react#11
```
FabricMountingManager output
```
Remove react#100 from react#11
Insert react#100 into react#11
Delete react#100
```

Note that the create action is also skipped, because we only update `allocatedViewTags` after processing all mutations, leading FabricMountingManager to assume creation is not required.

This leads to an invalid state in SurfaceMountingManager, which will be surfaced as a crash in `getViewState` on the next mutation that interacts with these views.

Changelog: [Android][Fixed] Fix crash in getViewState when using suspense fallbacks.

Reviewed By: sammy-SC

Differential Revision: D63148523
facebook-github-bot pushed a commit that referenced this pull request Oct 28, 2024
…46702)

Summary:
Pull Request resolved: #46702

In #44188, we've started combining multiple transactions in a single transaction, to meet React's atomicity requirements, while also dealing with the constraints of Android's Fabric implementation.

This revealed a bug where in some scenarios (especially when using transitions), a node may be deleted and created during the same transaction. The current implementation of FabricMountingManager assumes it can safely reorder some operations, which it does to optimize the size of IntBufferBatch mount items. This is however incorrect and unsafe when multiple transactions are merged.

**Example:**

Differentiator output:

```
# Transaction 1
Remove #100 from #11
Delete #100

# Transaction 2
Create #100
Insert #100 into #11
```
FabricMountingManager output
```
Remove #100 from #11
Insert #100 into #11
Delete #100
```

Note that the create action is also skipped, because we only update `allocatedViewTags` after processing all mutations, leading FabricMountingManager to assume creation is not required.

This leads to an invalid state in SurfaceMountingManager, which will be surfaced as a crash in `getViewState` on the next mutation that interacts with these views.

Changelog: [Android][Fixed] Fix crash in getViewState when using suspense fallbacks.

Reviewed By: sammy-SC

Differential Revision: D63148523

fbshipit-source-id: 07ae26b2f7b7eba1b9784041dd3059b0956c035e
SudoPlz pushed a commit to SudoPlz/react-native that referenced this pull request Sep 10, 2025
SudoPlz pushed a commit to SudoPlz/react-native that referenced this pull request Feb 16, 2026
SudoPlz pushed a commit to SudoPlz/react-native that referenced this pull request Feb 16, 2026
SudoPlz pushed a commit to SudoPlz/react-native that referenced this pull request Feb 16, 2026
piaskowyk added a commit to discord/react-native that referenced this pull request Sep 10, 2026
This reverts commit 9eee718.

The shadowTreeCommitSucceeded / shadowTreeCommitFinalized hooks existed
only to make Reanimated's props-registry equality eviction race-free.
That eviction turned out to be performance neutral and has been removed
from the Reanimated fork, so nothing overrides these hooks anymore and
the fork can drop the divergence from upstream in ShadowTree,
ShadowTreeDelegate, UIManager and UIManagerCommitHook.

Also restores the configureEventEmitterCallback() call in
SampleTurboModuleSpec.cpp, which that commit had incidentally commented
out.

Co-authored-by: Cursor <cursoragent@cursor.com>
piaskowyk added a commit to discord/react-native that referenced this pull request Sep 10, 2026
This reverts commit 9eee718.

The shadowTreeCommitSucceeded / shadowTreeCommitFinalized hooks existed
only to make Reanimated's props-registry equality eviction race-free.
That eviction turned out to be performance neutral and has been removed
from the Reanimated fork, so nothing overrides these hooks anymore and
the fork can drop the divergence from upstream in ShadowTree,
ShadowTreeDelegate, UIManager and UIManagerCommitHook.

Also restores the configureEventEmitterCallback() call in
SampleTurboModuleSpec.cpp, which that commit had incidentally commented
out.

Co-authored-by: Cursor <cursoragent@cursor.com>
piaskowyk added a commit to discord/react-native that referenced this pull request Oct 13, 2026
This reverts commit 9eee718.

The shadowTreeCommitSucceeded / shadowTreeCommitFinalized hooks existed
only to make Reanimated's props-registry equality eviction race-free.
That eviction turned out to be performance neutral and has been removed
from the Reanimated fork, so nothing overrides these hooks anymore and
the fork can drop the divergence from upstream in ShadowTree,
ShadowTreeDelegate, UIManager and UIManagerCommitHook.

Also restores the configureEventEmitterCallback() call in
SampleTurboModuleSpec.cpp, which that commit had incidentally commented
out.

Co-authored-by: Cursor <cursoragent@cursor.com>
delekta added a commit to discord/react-native that referenced this pull request Nov 4, 2026
* Revert "[Android] shadow-tree commit-lifecycle hooks (react#100)"

This reverts commit 9eee718.

The shadowTreeCommitSucceeded / shadowTreeCommitFinalized hooks existed
only to make Reanimated's props-registry equality eviction race-free.
That eviction turned out to be performance neutral and has been removed
from the Reanimated fork, so nothing overrides these hooks anymore and
the fork can drop the divergence from upstream in ShadowTree,
ShadowTreeDelegate, UIManager and UIManagerCommitHook.

Also restores the configureEventEmitterCallback() call in
SampleTurboModuleSpec.cpp, which that commit had incidentally commented
out.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Add enableMountingCoordinatorPullModelAndroid feature flag (react#57581)

Adds the `enableMountingCoordinatorPullModelAndroid` experiment flag
(default off) that gates the Android pull-model mounting migration.
Config entry plus regenerated accessors only - no behavior change.

Cherry-pick of react/react-native@ece0efe.

The generated feature flag files conflicted because this fork's flag set
has diverged from upstream, so they were regenerated from the config with
`yarn featureflags` instead of being merged by hand.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Default enableMountingCoordinatorPullModelAndroid to true

Flip the flag's defaultValue to true and regenerate the feature-flag
boilerplate with `yarn featureflags --update`. The config's own metadata
already declared expectedReleaseValue: true.

Neither app-side provider overrides the flag, so the default applies
directly: ReactNativeNewArchitectureFeatureFlagsDefaults (Android) and
ReactNativeFeatureFlagsOverridesOSSStable (iOS) both inherit it.

Note: this is inert on this branch. The flag has no consumers here or
upstream at ece0efe -- that commit only defines it, and the migration it
gates (PullTransactionMountItem enqueued in MountItemDispatcher, so the UI
thread pulls the transaction instead of the commit thread building the
batch in schedulerShouldRenderTransactions) lands in later upstream
commits that are not cherry-picked here. Setting true now records intent
so the path is on once the implementation arrives.

This is a separate mechanism from usePullModelOnAndroid, which this fork
already defaults to true and which does have consumers in
FabricUIManagerBinding.cpp and FabricUIManager.java. Upstream has since
removed that flag, having graduated it.

Before the implementation is backported, check the dependencies named in
the flag description: enableAccumulatedUpdatesInRawPropsAndroid is already
true, but enableExclusivePropsUpdateAndroid and
enablePropsUpdateReconciliationAndroid are both still false, and the
latter two are required when Props 2.0 is in use.

Co-authored-by: Cursor <cursoragent@cursor.com>

* [Discord] Enable preventShadowTreeCommitExhaustion by default

Reanimated requires this React Native flag to be enabled before its own
DISABLE_COMMIT_PAUSING_MECHANISM flag can be turned on safely; without it,
React commits can be starved and the app becomes unresponsive.

See https://docs.swmansion.com/react-native-reanimated/docs/guides/feature-flags/#disable_commit_pausing_mechanism

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Krzysztof Piaskowy <krzysztof.piaskowy@discordapp.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Dawid Małecki <maleckidawid@meta.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant