Repository navigation
fix(android): don't preallocate a view that a commit already created - #60019
erennyuksell wants to merge 2 commits into
Conversation
The preallocation queue is drained on the UI thread, so a commit can get there first. When a commit creates a view and the next one deletes it again (a View flattened right after it mounts), executeMount adds the tag to allocatedViewTags and erases it before the drain runs. The drain then registers the tag as preallocated and creates the Java view, which the queued DELETE removes, so the tag stays allocated with no view behind it. The next CREATE for that family is skipped and the next REMOVE throws "Unable to find parentView for tag". Skip the drain for a family that is already part of a committed tree: its view is executeMount's to create from then on.
|
Hi @erennyuksell! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
@javache has imported this pull request. If you are a Meta employee, you can view this in D132239159. |
|
Please run formatter |
Visual regressionNo visual differences at android: no capture ios: no capture |
Summary:
Fixes #60018, and I believe #58526 too.
The preallocation queue is drained on the UI thread, so a commit can get there first. If the commit creates a view and the next commit deletes it again (a View that is flattened right after it mounts, e.g.
opacityset and cleared in a layout effect),executeMountadds the tag toallocatedViewTagsand erases it before the drain runs. The drain then finds the tag missing, registers it as preallocated and creates the Java view, which the queuedDELETEremoves. The tag stays allocated in C++ with no view behind it. The nextCREATEfor that family is skipped, the inserts land in a view that doesn't exist, and the nextREMOVEcrashes withUnable to find parentView for tag.This skips the drain for a family that is already part of a committed tree (
ShadowNodeFamily::hasBeenMounted()). Its view belongs toexecuteMountfrom then on. The check runs underallocatedViewsMutex_, whichexecuteMounttakes after the commit has marked the family, so the two can't interleave in a way that brings the tag back. Views that haven't been committed yet are still preallocated as before.Changelog:
[ANDROID] [FIXED] - Fix a crash in
removeViewAtwhen a view is flattened in the commit right after it mounts while its preallocation is still queuedTest Plan:
Added two cases to
FabricMountingManagerInstrumentationTest(withcommitQueuedViewandexecuteDeleteMutationon the test helper): a queued view that a commit created and deleted is not registered by the drain, and a view no commit has taken yet still is. These run only in the internal build (the OSS Gradle build excludes this test), so I couldn't run them myself.What I did run, on an API 36 emulator with a release build:
0.88 doesn't have
QueuedVieworShadowNodeFamily::hasBeenMounted()yet, so for that build I carried the family in the queue and added the getter, same as main.