-
Notifications
You must be signed in to change notification settings - Fork 6k
Fix Shell::Screenshot for Impeller #50072
Conversation
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 this seems pretty solid
shell/common/rasterizer.cc
Outdated
latch.Signal(); | ||
return; | ||
} | ||
auto buffer_view = impeller::DeviceBuffer::AsBufferView(buffer); |
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: unused?
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.
removed it.
root_surface_transformation.reset(); | ||
|
||
auto frame = compositor_context.AcquireFrame( | ||
surface_context, // skia 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.
The style for these should be /*arg_name=*/
so that they are checked by the linter.
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 in follow up.
|
||
impeller::DlDispatcher dispatcher; | ||
builder.Build()->Dispatch(dispatcher); | ||
const auto& picture = dispatcher.EndRecordingAsPicture(); |
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.
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 think this one is pretty clear.
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.
It's not if it is clear to you, "Use type deduction only if it makes the code clearer to readers who aren't familiar with the project, or if it makes the code safer. Do not use it merely to avoid the inconvenience of writing an explicit type."
This isn't my personal style, I'm just reporting based on the style guide we've agreed to follow =)
auto buffer = | ||
impeller_context->GetResourceAllocator()->CreateBuffer(buffer_desc); | ||
auto command_buffer = impeller_context->CreateCommandBuffer(); | ||
command_buffer->SetLabel("BlitTextureToBuffer Command Buffer"); |
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.
This code is very similar to the code we have in vulkan_screenshotter.cc
. Despite the name, it's actually doing this. It would be nice if we could share this. PTAL.
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.
There's a few places we have code a little like this, and trying to clean all of them up was getting to be pretty invasive. I think it's worth doing but didn't want to block the rest of this fix on it.
&latch](impeller::CommandBuffer::Status status) { | ||
if (status != impeller::CommandBuffer::Status::kCompleted) { | ||
FML_LOG(ERROR) << "Failed to complete blit pass."; | ||
latch.Signal(); |
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: put this in a fml::ScopedCleanup.
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.
UIViewController* rootVC = appDelegate.window.rootViewController; | ||
[rootVC presentViewController:self.flutterViewController animated:NO completion:nil]; | ||
|
||
CGColorSpaceRef color_space = CGColorSpaceCreateDeviceRGB(); |
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 believe this is leaking, there should be a CGColorSpaceRelease.
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.
Adding this in a follow up, and for the CGContextRelease
return; | ||
} | ||
|
||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC), dispatch_get_main_queue(), |
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.
you can just use dispatch_async here and below
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 want a delay so we get a chance to render some frames.
final PictureRecorder recorder = PictureRecorder(); | ||
final Canvas canvas = Canvas(recorder); | ||
|
||
canvas.drawPaint(Paint()..color = const Color(0xFF0000FF)); |
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.
This is in BGRA? I would have expected RGBA at this level, probably worth commenting.
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.
It's ARGB - this is the normal dart:ui color class...
sorry, late to the party, there is a few things in there that should be fixed (like the leak) |
…142347) flutter/engine@525bd7d...a65a1b5 2024-01-26 [email protected] Roll Skia from c32aa37effcc to 6279c88b9e29 (1 revision) (flutter/engine#50098) 2024-01-26 [email protected] [Impeller] add compute pass API for memory barriers, re-enable for Vulkan. (flutter/engine#49946) 2024-01-26 [email protected] Introduce a prototype of a "header guard enforcement" tool (flutter/engine#48903) 2024-01-26 [email protected] Roll Skia from e24124912cc3 to c32aa37effcc (1 revision) (flutter/engine#50094) 2024-01-26 [email protected] [web] Do not wipe the PlatformViewManager when disposing of a view. (flutter/engine#49991) 2024-01-26 [email protected] Finish landing missing/incorrect header guards across `flutter/engine` (flutter/engine#50069) 2024-01-26 [email protected] Roll Skia from 32f6bff0f193 to e24124912cc3 (2 revisions) (flutter/engine#50093) 2024-01-26 [email protected] Roll Skia from cbdf09d69efc to 32f6bff0f193 (3 revisions) (flutter/engine#50092) 2024-01-26 [email protected] Roll Dart SDK from 5636e338e0b9 to 7337995bc851 (1 revision) (flutter/engine#50087) 2024-01-26 [email protected] Fix Shell::Screenshot for Impeller (flutter/engine#50072) 2024-01-26 [email protected] Roll Skia from ae73baacb793 to cbdf09d69efc (1 revision) (flutter/engine#50085) 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],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
`FlutterViewControllerTest testDrawLayer` created a callback which strongly referenced itself in its own body as part of an asynchronous recursive loop. The recursion was unnecessary and the test consistently passes, even if run on repeat > 100 times without it. Now that there's only one call, eliminates the unnecessary local and inlines it into the `dispatch_after` call. This was originally introduced in #50072. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
…6249) `FlutterViewControllerTest testDrawLayer` created a callback which strongly referenced itself in its own body as part of an asynchronous recursive loop. The recursion was unnecessary and the test consistently passes, even if run on repeat > 100 times without it. Now that there's only one call, eliminates the unnecessary local and inlines it into the `dispatch_after` call. This was originally introduced in flutter/engine#50072. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Fixes flutter/flutter#141571
Shell::Screenshot was impelemnted in a Skia-only way and would crash when invoked. Adds test coverage for the breaking path on iOS that ends up calling
FlutterView drawLayer
.