-
Notifications
You must be signed in to change notification settings - Fork 6k
Avoid dereferencing IO manager weak pointers on the UI thread #13232
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,6 +78,10 @@ const TaskRunners& UIDartState::GetTaskRunners() const { | |
| return task_runners_; | ||
| } | ||
|
|
||
| fml::WeakPtr<IOManager> UIDartState::GetIOManager() const { | ||
| return io_manager_; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we be vending a new WeakPtr here by calling io_manager_->GetWeakIOManager()?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The UI thread can safely copy |
||
| } | ||
|
|
||
| fml::RefPtr<flutter::SkiaUnrefQueue> UIDartState::GetSkiaUnrefQueue() const { | ||
| // TODO(gw280): The WeakPtr here asserts that we are derefing it on the | ||
| // same thread as it was created on. As we can't guarantee that currently | ||
|
|
@@ -119,14 +123,6 @@ void UIDartState::AddOrRemoveTaskObserver(bool add) { | |
| } | ||
| } | ||
|
|
||
| fml::WeakPtr<GrContext> UIDartState::GetResourceContext() const { | ||
| FML_DCHECK(task_runners_.GetIOTaskRunner()->RunsTasksOnCurrentThread()); | ||
| if (!io_manager_) { | ||
| return {}; | ||
| } | ||
| return io_manager_->GetResourceContext(); | ||
| } | ||
|
|
||
| fml::WeakPtr<ImageDecoder> UIDartState::GetImageDecoder() const { | ||
| return image_decoder_; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,9 +48,9 @@ class UIDartState : public tonic::DartState { | |
|
|
||
| void FlushMicrotasksNow(); | ||
|
|
||
| fml::RefPtr<flutter::SkiaUnrefQueue> GetSkiaUnrefQueue() const; | ||
| fml::WeakPtr<IOManager> GetIOManager() const; | ||
|
|
||
| fml::WeakPtr<GrContext> GetResourceContext() const; | ||
| fml::RefPtr<flutter::SkiaUnrefQueue> GetSkiaUnrefQueue() const; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also delete this method and expect callees to go through the IOManager as well? It seems like that should be the direction we go down - but I'm happy to defer this to another issue (and file one to track that) instead of overloading this PR.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally we should never dereference Fixing this for |
||
|
|
||
| fml::WeakPtr<ImageDecoder> GetImageDecoder() const; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noooo. The slashes.