-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delay metal drawable acquisition till frame submission. #13367
Conversation
Uses the new `SkSurface::MakeFromCAMetalLayer` Skia API.
bounds.height * scale, // height | ||
1, // sample count | ||
metal_texture_info // metal texture info | ||
auto surface = SkSurface::MakeFromCAMetalLayer(context_.get(), // context |
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.
Does next_drawable_ get set synchronously here?
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.
No. This will defer the next drawable acquisition till much later. In fact, it is almost guaranteed to not be set after this call. I would have captured it in one of the scoped wrappers otherwise.
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.
What happens if the next_drawable_
isn't set until after we check if it's null in the callback?
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.
The next GPUSurfaceMetal::AcquireFrame
will collect it if there is a next frame. GPUSurfaceMetal::~GPUSurfaceMetal
will collect it via ReleaseUnusedDrawableIfNecessary
if there isn't.
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.
I should mention that either case is extremely unlikely because the surface frame itself is collected immediately after submission.
canvas->flush(); | ||
if (!hasExternalViewEmbedder) { | ||
|
||
if (next_drawable_ == nullptr) { |
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 it possible that this callback gets invoked between lines 101 and 104 above?
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.
No. These are on the same thread and tasks are posted serially.
shell/gpu/gpu_surface_metal.mm
Outdated
// External views need to present with transaction. When presenting with | ||
// transaction, we have to block, otherwise we risk presenting the drawable | ||
// after the CATransaction has completed. | ||
// See: | ||
// https://developer.apple.com/documentation/quartzcore/cametallayer/1478157-presentswithtransaction | ||
// TODO(dnfield): only do this if transactions are actually being used. | ||
// https://github.com/flutter/flutter/issues/24133 |
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.
nit: maybe we should move this comment down to line 143 now, since we're no longer getting whether it's an external view embedder here.
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.
Done.
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.
Do the platform view tests pass on the metal backend with this? We only run them on OpenGL on CI AFAIK.
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.
Addressed all comments. I also missed a release of the drawable when the surface itself is collected without pending surface frame submission.
Do the platform view tests pass on the metal backend with this?
Yes, but this needs to be automated. Tracking in flutter/flutter#43649
bounds.height * scale, // height | ||
1, // sample count | ||
metal_texture_info // metal texture info | ||
auto surface = SkSurface::MakeFromCAMetalLayer(context_.get(), // context |
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.
No. This will defer the next drawable acquisition till much later. In fact, it is almost guaranteed to not be set after this call. I would have captured it in one of the scoped wrappers otherwise.
shell/gpu/gpu_surface_metal.mm
Outdated
// External views need to present with transaction. When presenting with | ||
// transaction, we have to block, otherwise we risk presenting the drawable | ||
// after the CATransaction has completed. | ||
// See: | ||
// https://developer.apple.com/documentation/quartzcore/cametallayer/1478157-presentswithtransaction | ||
// TODO(dnfield): only do this if transactions are actually being used. | ||
// https://github.com/flutter/flutter/issues/24133 |
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.
Done.
canvas->flush(); | ||
if (!hasExternalViewEmbedder) { | ||
|
||
if (next_drawable_ == nullptr) { |
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.
No. These are on the same thread and tasks are posted serially.
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.
LGTM
git@github.com:flutter/engine.git/compare/49971e21402e...25563a1 git log 49971e2..25563a1 --no-merges --oneline 2019-10-29 iska.kaushik@gmail.com Update recipe_changelog to account for dart_aot runner and clobbering 2019-10-28 iska.kaushik@gmail.com Revert "[flutter_runner] Don't build far files twice (#13397)" (flutter/engine#13400) 2019-10-28 matthew-carroll@users.noreply.github.com Remove multiplexed Flutter Android Lifecycle. (#43663) (flutter/engine#13394) 2019-10-28 iska.kaushik@gmail.com [flutter_runner] Don't build far files twice (flutter/engine#13397) 2019-10-28 chinmaygarde@google.com Delay metal drawable acquisition till frame submission. (flutter/engine#13367) 2019-10-28 skia-flutter-autoroll@skia.org Roll fuchsia/sdk/core/mac-amd64 from 9MM-e... to mc3jR... (flutter/engine#13390) 2019-10-28 bkonyi@google.com Roll src/third_party/dart 5e39817ec7..e1fce75301 (2 commits) 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 aaclarke@google.com 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
git@github.com:flutter/engine.git/compare/49971e21402e...25563a1 git log 49971e2..25563a1 --no-merges --oneline 2019-10-29 iska.kaushik@gmail.com Update recipe_changelog to account for dart_aot runner and clobbering 2019-10-28 iska.kaushik@gmail.com Revert "[flutter_runner] Don't build far files twice (flutter#13397)" (flutter/engine#13400) 2019-10-28 matthew-carroll@users.noreply.github.com Remove multiplexed Flutter Android Lifecycle. (flutter#43663) (flutter/engine#13394) 2019-10-28 iska.kaushik@gmail.com [flutter_runner] Don't build far files twice (flutter/engine#13397) 2019-10-28 chinmaygarde@google.com Delay metal drawable acquisition till frame submission. (flutter/engine#13367) 2019-10-28 skia-flutter-autoroll@skia.org Roll fuchsia/sdk/core/mac-amd64 from 9MM-e... to mc3jR... (flutter/engine#13390) 2019-10-28 bkonyi@google.com Roll src/third_party/dart 5e39817ec7..e1fce75301 (2 commits) 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 aaclarke@google.com 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
Uses the new
SkSurface::MakeFromCAMetalLayer
Skia API. Fixes flutter/flutter#41829