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

Conversation

@cyanglaz
Copy link
Contributor

@cyanglaz cyanglaz commented Apr 20, 2023

DisposeView happens every frame before laying out PlatformViews, with the order specified in composition_order_. Because view_to_dispose_ is determined on UI thread and composition_order_ is determined on the platform thread, there could be a race if the dart code on the UI thread runs faster than the rasterizer on the Platform thread, causing a view in view_to_dispose_ is still in the composition_order_.

When this happens, we should delay the views in the composition_order_ being disposed and wait for the next frame to dispose them.

fixes flutter/flutter#125223

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.

@cyanglaz cyanglaz requested a review from hellohuanlin April 20, 2023 18:17
@cyanglaz cyanglaz marked this pull request as ready for review April 20, 2023 18:17
fix
remove from slice

test
@cyanglaz cyanglaz force-pushed the platform_view_crash branch from 0396655 to c3485fa Compare April 20, 2023 18:18
@hellohuanlin
Copy link
Contributor

hellohuanlin commented Apr 20, 2023

I may need some help understanding the logic of what these fields are for, but first of all, DisposeViews() is called in main thread (from the FML_DCHECK), is it ok to directly modify composition_order_ (which is also updated in raster thread, described in github issue)? Does the caller of DisposeViews() already guarantee the thread safety?

Maybe im missing something. let me know if you wanna sync.

@cyanglaz
Copy link
Contributor Author

cyanglaz commented Apr 20, 2023

Oh actually, composition_order_ is updated on the main thread. The raster thread and main thread are merged. I need to clarify it in the issue.

Copy link

@saintmac-google saintmac-google left a comment

Choose a reason for hiding this comment

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

Tested on our app, it works fine :)

@cyanglaz cyanglaz marked this pull request as draft April 25, 2023 21:48
@cyanglaz
Copy link
Contributor Author

Closing in favor of #41521

@cyanglaz cyanglaz closed this May 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ios_platform_view] crash due to race when disposing platform views.

3 participants