Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@ditman
Copy link
Member

@ditman ditman commented Apr 27, 2022

When computing the diff of embedded views between a frame and the next (diffViewList), prevent viewIds from being returned both in the viewsToRemove and viewsToAdd of the diff (prefer them on viewsToAdd).

If we let the diff remove views that are going to be added immediately afterwards, they get disposed of and then they cause a null access error when the engine attempts to add them a few lines below (the framework would need an extra frame to re-inject the missing view after it's been removed).

The browser is able to understand that we want to "move" an html element just by adding it elsewhere; so the solution is to ensure that viewsToRemove and viewsToAdd do not share view ids. (or: remove all viewIds from viewsToRemove that are going to be added by viewsToAdd).

Tests

  • Added some extra unit tests for the new behavior (the old tests were passing after my changes!).

Issue

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

When computing the diff of embedded views between a frame and the next
(diffViewList), remove all views from viewsToRemove that are also in
viewsToAdd.

The framework needs a frame to re-render a view after it's been removed,
and the browser is able to understand that we want to "move" a view,
just by adding it elsewhere.

Added some extra unit tests for the new behavior.
@ditman ditman requested a review from harryterkelsen April 27, 2022 03:01
@flutter-dashboard flutter-dashboard bot added the platform-web Code specifically for the web engine label Apr 27, 2022
}
}

// Remove all ids from viewsToRemove that also exist in viewsToAdd.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely sure how to trigger/test this case, but looking at how the code accesses the viewClipChain, this branch of the code seems also vulnerable to the same error :/

Copy link
Contributor

@harryterkelsen harryterkelsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ditman ditman added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Apr 27, 2022
@fluttergithubbot fluttergithubbot merged commit 94824fc into flutter:main Apr 27, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 27, 2022
@ditman ditman deleted the ck-preserve-views-in-diffViewList branch April 27, 2022 20:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

platform-web Code specifically for the web engine waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.

Projects

None yet

3 participants