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

[fuchsia] SceneHostBindings are no longer thread locals #16262

Merged
merged 3 commits into from
Jan 30, 2020

Conversation

iskakaushik
Copy link
Contributor

Prior to this change SceneHostBindinds was a ThreadLocal but the
intention was for it to be IsolateLocal. Given that dart
could collect this map on a non-UI thread this caused
use-after-free issues.

This change fixes it by making it keyed on isolate and koid
this is not the ideal solution, this would exist on
dart isolate group data struct. Given that Fuchsia is moving
to use the embedder API, the decision to use this temporary
work around was made.

fixes flutter/flutter#49738

#include "flutter/fml/memory/ref_counted.h"
#include "flutter/fml/task_runner.h"
#include "flutter/lib/ui/dart_wrapper.h"

namespace flutter {

struct SceneHostBindingKey {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you move all of this and the #include into the .cc file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup!

@iskakaushik iskakaushik force-pushed the yilong-issue branch 2 times, most recently from 80d4e9d to f4b2f32 Compare January 30, 2020 19:55
#include "flutter/flow/view_holder.h"
#include "flutter/fml/thread_local.h"
#include "flutter/lib/ui/ui_dart_state.h"

namespace {

using SceneHostBindings = std::unordered_map<zx_koid_t, flutter::SceneHost*>;
struct SceneHostBindingKey {
Dart_Isolate associated_isolate;
Copy link
Member

Choose a reason for hiding this comment

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

Call Dart_IsolateServiceId and use that to represent the isolate. A raw isolate handle can become invalid at any time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good call, thanks @jason-simmons

Prior to this change SceneHostBindinds was a ThreadLocal but the
intention was for it to be IsolateLocal. Given that dart
could collect this map on a non-UI thread this caused
use-after-free issues.

This change fixes it by making it keyed on isolate and koid
this is not the ideal solution, this would exist on
dart isolate group data struct. Given that Fuchsia is moving
to use the embedder API, the decision to use this temporary
work around was made.

fixes flutter/flutter#49738
@iskakaushik iskakaushik merged commit 9361ee5 into flutter:master Jan 30, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 31, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 31, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 31, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 31, 2020
engine-flutter-autoroll added a commit to flutter/flutter that referenced this pull request Jan 31, 2020
flutter/engine@74d07b5...804dca6

git log 74d07b5..804dca6 --first-parent --oneline
2020-01-31 [email protected] Use bundled Roboto in all tests (flutter/engine#16218)
2020-01-31 [email protected] Revert "Migrate flutter_runner from flutter_runner::{Thread,Loop} to fml::{Thread,MessageLoop} (#15118)" (flutter/engine#16277)
2020-01-31 [email protected] Roll src/third_party/skia 36c0521d57de..6305b2f8342a (8 commits) (flutter/engine#16272)
2020-01-31 [email protected] Revert "[web] Correct getPositionForOffset for multi-line paragraphs (#16206)" (flutter/engine#16268)
2020-01-30 [email protected] Fix Windows file checks of unicode paths (flutter/engine#16105)
2020-01-30 [email protected] [fuchsia] Fix the import for dart_api.h (flutter/engine#16269)
2020-01-30 [email protected] [fuchsia] SceneHostBindings are no longer thread locals (flutter/engine#16262)
2020-01-30 [email protected] Pass through invoker.resources in fuchsia_test_archive (flutter/engine#16265)
2020-01-30 [email protected] Notify PlatformViewsController within FlutterEngine when a hot restart occurs. (#48518) (flutter/engine#16230)
2020-01-30 [email protected] Roll src/third_party/dart fc3af737c759..162d6c5634a0 (209 commits) (flutter/engine#16261)
2020-01-30 [email protected] Roll src/third_party/skia d1be5d64f8a7..36c0521d57de (13 commits) (flutter/engine#16260)
2020-01-30 [email protected] [web] Correct getPositionForOffset for multi-line paragraphs (flutter/engine#16206)
2020-01-30 [email protected] Roll fuchsia/sdk/core/linux-amd64 from -mGIA... to 93K0d... (flutter/engine#16257)


If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected] on the revert to ensure that a human
is aware of the problem.

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+/master/autoroll/README.md
NoamDev pushed a commit to NoamDev/engine that referenced this pull request Feb 27, 2020
Prior to this change SceneHostBindinds was a ThreadLocal but the
intention was for it to be IsolateLocal. Given that dart
could collect this map on a non-UI thread this caused
use-after-free issues.

This change fixes it by making it keyed on isolate and koid
this is not the ideal solution, this would exist on
dart isolate group data struct. Given that Fuchsia is moving
to use the embedder API, the decision to use this temporary
work around was made.

fixes flutter/flutter#49738
NoamDev added a commit to NoamDev/engine that referenced this pull request Feb 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flutter crashes when swiping the screen
4 participants