-
Notifications
You must be signed in to change notification settings - Fork 6k
Discard wrong size layer tree instead of rendering it #21179
Discard wrong size layer tree instead of rendering it #21179
Conversation
If this callback returns true for given layer tree, the layer tree will be discarded and not rasterized This is useful after the resize event, when layer tree with certain size is expected, but there is a tree with previous size still in pipeline
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
Looks good overall but requires tests as mentioned in this comment: #21108 (review). Let me know if you run into issues writing tests. |
981a8f5 to
9dab1f2
Compare
iskakaushik
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.
Left some improvements to the test, we should be good to merge this PR once those are fixed.
shell/common/shell_unittests.cc
Outdated
| auto layer_tree = | ||
| std::make_unique<LayerTree>(size, static_cast<float>(1)); | ||
| SkMatrix identity; | ||
| identity.setIdentity(); |
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: I thought SkMatrix was default initialized to identiy.
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 copied that snippet from another test, but you're right. Unlike other types SkMatrix actually seems to have sane default value.
shell/common/shell_unittests.cc
Outdated
| shell->GetTaskRunners().GetPlatformTaskRunner(), | ||
| [&shell, &expected_size]() { | ||
| shell->GetPlatformView()->SetViewportMetrics( | ||
| {1.0, double(expected_size.width()), |
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: can these be static_cast<double>?
shell/common/shell_unittests.cc
Outdated
| shell->GetTaskRunners().GetUITaskRunner()->PostTask( | ||
| [runtime_delegate, size]() { | ||
| auto layer_tree = | ||
| std::make_unique<LayerTree>(size, static_cast<float>(1)); |
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: this can be 1.0f.
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.
Indeed. Not sure why it was written like this.
642e383 to
58f1b71
Compare
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 this still a WIP or do you think we can land this once the presubmits pass?
If you think it's ready, please remove WIP from the title of the PR.
| GrDirectContext* context, | ||
| std::unique_ptr<SurfaceFrame> frame) { | ||
| frame->Submit(); | ||
| if (frame && frame->SkiaSurface()) { |
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.
Windows toolchain doesn't seem to be liking this:
C:\b\s\w\ir\kitchen-checkout\depot_tools\win_toolchain\vs_files\418b3076791776573a815eb298c8aa590307af63\win_sdk\bin\..\..\VC\Tools\MSVC\14.16.27023\include\atomic(620,2): error: static_assert failed due to requirement 'alignof(SkISize) >= sizeof(unsigned long long)' "You've instantiated std::atomic<T> with sizeof(T) equal to 2/4/8 and alignof(T) < sizeof(T). Before VS 2015 Update 2, this would have misbehaved at runtime. VS 2015 Update 2 was fixed to handle this correctly, but the fix inherently changes layout and breaks binary compatibility. Please define _ENABLE_ATOMIC_ALIGNMENT_FIX to acknowledge that you understand this, and that everything you're linking has been compiled with VS 2015 Update 2 (or later)."
static_assert(alignof(_Ty) >= sizeof(_My_int),
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\b\s\w\ir\kitchen-checkout\depot_tools\win_toolchain\vs_files\418b3076791776573a815eb298c8aa590307af63\win_sdk\bin\..\..\VC\Tools\MSVC\14.16.27023\include\atomic(635,5): note: in instantiation of template class 'std::_Atomic_base<SkISize, 8>' requested here
: _Atomic_base<_Ty, sizeof (_Ty)>
^
../../flutter/shell/common/shell_test_external_view_embedder.h(86,24): note: in instantiation of template class 'std::atomic<SkISize>' requested here
std::atomic<SkISize> last_submitted_frame_size_;
^
1 error generated.
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 isn't going to be an issue in future, in the meanwhile perhaps we could define _ENABLE_ATOMIC_ALIGNMENT_FIX. There's nothing wrong with the code, it's just a windows STL quirk.
shell/common/shell_unittests.cc
Outdated
| end_frame_latch.Signal(); | ||
| }; | ||
|
|
||
| external_view_embedder = std::make_shared<ShellTestExternalViewEmbedder>( |
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: declare this variable here rather than line:2020. See https://google.github.io/styleguide/cppguide.html#Local_Variables
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.
Yeah. It was accessed from the callback before. I'll move it.
1a57215 to
146a855
Compare
|
@knopp I still see two errors only on windows: and Still seem to be artifacts of STL on windows? |
|
It is artifact of windows STL, but the define on top of the file should have taken care of it. I'm building now on windows locally. |
a78fe6f to
19dad88
Compare
|
seems like formatting is off in |
08257a4 to
1e524f5
Compare
1e524f5 to
9fccda2
Compare
iskakaushik
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.
LGTM
Description
This PR supersedes #21108.
This PR will ensure that after viewport change metrics event is received, layer tree with previous (wrong size) are discarded and not rasterized. This is required for smooth resizing on both Mac and Windows.
Important: This will potentially affect iOS and Android embedders. We need to make sure this doesn't cause any issues.
Related Issues
flutter/flutter#44136
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.Breaking Change
Did any tests fail when you ran them? Please read handling breaking changes.