-
Notifications
You must be signed in to change notification settings - Fork 6k
started providing the GPU sync switch to external view embedders #22302
started providing the GPU sync switch to external view embedders #22302
Conversation
a47b796 to
d4cd120
Compare
cyanglaz
left a comment
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.
Code looks good. I have no clue what does gpu_disable_sync_switch do and how it works. Let's add another reviewer who knows this better?
…hey can block background gpu calls
| const std::shared_ptr<fml::SyncSwitch>& gpu_disable_sync_switch) { | ||
| bool result = false; | ||
| gpu_disable_sync_switch->Execute( | ||
| fml::SyncSwitch::Handlers().SetIfTrue([&] { result = false; }).SetIfFalse([&] { |
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.
Is the SetIfTrue handler necessary? result is already set to false by default
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.
Nope, it shouldn't be necessary. Once I get things sorted out I'll try removing it.
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.
Oh, shoot I forgot to do this before it landed. I was in a rush. It's probably not a big deal, if you want it gone I can do it in a separate PR. Sorry.
d1a355a to
e272675
Compare
|
@gaaclarke , @cyanglaz - I came across this change. Do you know why not clearing the current pending raster tasks in
|
|
@blasten If we synchronously flushed all outstanding GPU tasks on the raster thread for the external view embedder when we got the ResignActive notification and guaranteed that it will never attempt another GPU tasks until the app has become active again that would be a valid way to solve this issue, too. Is that what you are asking? |
|
@gaaclarke yep. @cyanglaz mentioned that the crash would happen here https://github.com/flutter/engine/blob/master/shell/common/rasterizer.cc#L438 because we teared down the surface from the link I mentioned above. It sounds like we need a primitive to ensure that all pending tasks are flushed and that the queue is disabled. |
|
@blasten Check out the issue this PR addresses, the stacktrace of the crash is there. It's from the external view embedder executing GPU operations. This PR causes the platform thread to wait for GPU operations to execute before exiting, then turns them off atomically. Any other attempts at creating frames in the background will be dropped. It's the same mechanism we use elsewhere like the decoding of images on background threads. |
|
right. I guess my question is more about defining some primitives that work well across platforms. Do you know if we need to do this for Android too? |
|
I believe iOS is the only platform we currently support that has the requirement that GPU access may be blocked. Android at least doesn't crash, for energy reason we might want to disable GPU operations in the background if the operating system isn't already handling that gracefully. |
) (#22760) Co-authored-by: gaaclarke <30870216+gaaclarke@users.noreply.github.com>
…ers (flutter#22302)" This reverts commit 1c3bc02.
Description
External view embedders may be doing work on the GPU and they have to make sure they don't do so while the app is in the background.
I considered first making this a parameter to the ios_external_view_embedder but decided against it because:
Related Issues
fixes flutter/flutter#69642
Tests
I added the following tests:
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.Reviewer Checklist
Breaking Change
Did any tests fail when you ran them? Please read handling breaking changes.