-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Add dump-shader-skp switch to help ShaderWarmUp #8148
Conversation
@@ -37,6 +37,8 @@ | |||
public static final String ARG_SKIA_DETERMINISTIC_RENDERING = "--skia-deterministic-rendering"; | |||
public static final String ARG_KEY_TRACE_SKIA = "trace-skia"; | |||
public static final String ARG_TRACE_SKIA = "--trace-skia"; | |||
public static final String ARG_KEY_DUMP_SHADER_SKP = "dump-shader-skp"; |
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 these need to be pulled out of the Intent
in fromIntent()
?
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.
Good catch! Fixed.
Interestingly, we also have a similar logic in FlutterActivityDelegate.java. What's the difference between the two?
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.
FlutterActivityDelegate
is a mechanism in the old version of the embedding. FlutterShellArgs
is part of the new embedding.
shell/common/rasterizer.cc
Outdated
if (DrawToSurface(*layer_tree)) { | ||
last_layer_tree_ = std::move(layer_tree); | ||
} | ||
|
||
#if FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE | ||
if (persistent_cache->IsDumpingSkp() && persistent_cache->IsAccessed()) { |
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.
Instead of the #ifdefs, can all of this just be made conditional on IsDumpingSkp
(which presumably will be false in release mode)
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 agree. Let's make sure all the code compiles in all configurations. LTO should get rid of the unreachable code anyway. I also followed the same pattern in the raster cache which I will correct.
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.
Ok, then I'll remove those #ifdef
s assuming that there won't be a big impact on our binary code size. @goderbauer : if you find any significant regression related to this PR, please let me know and I'm happy to either revert it or add the #ifdef
s back.
shell/common/persistent_cache.cc
Outdated
|
||
std::stringstream name_stream; | ||
int current_index = skp_index_++; | ||
skp_index_ %= kMaxSkpIndex; |
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.
Why limit the maximum number of pictures captured? I'd suggest appending the timestamp to the end of the skp as well (std::to_string(fml::TimePoint::Now()
or something)). Just so its in increasing order. This is a profiling feature anyway so the disk usage is not a concern.
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.
shell/common/persistent_cache.cc
Outdated
skp_index_ %= kMaxSkpIndex; | ||
name_stream << "shader_dump_" << current_index << ".skp"; | ||
std::string file_name = name_stream.str(); | ||
FML_LOG(INFO) << "Dumping " << file_name; |
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.
Did you mean to leave this log in here? We don't display this log level 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.
Yes, I see that only --verbose-logging
will display such logs. I'll just leave it here and either send --verbose-logging
manually or wait flutter/flutter#29320 to be fixed 😃
shell/common/persistent_cache.cc
Outdated
@@ -81,6 +81,7 @@ bool PersistentCache::IsValid() const { | |||
// |GrContextOptions::PersistentCache| | |||
sk_sp<SkData> PersistentCache::load(const SkData& key) { | |||
TRACE_EVENT0("flutter", "PersistentCacheLoad"); | |||
is_accessed_ = true; |
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.
Aren't we only interested in pictures where a persistent cache entry is stored? In cases of cache loads, we are already reusing something that we have seen (and cached) before. My anticipation of the logic was:
- Skia asks us to store shaders for a new picture we have never seen before.
- We store the skp for that picture.
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.
Thinking about this some more: Maybe you didn't mean for this feature to say "give me the SKP dumps of new pictures that cause shader compilations", but instead, "give me all SKP dumps of pictures that already caused shader compilations". If the latter is the case, just look for all SKPs on disk. Either way, the is_accessed
logic I think can be made more elegant.
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. Changed the flag to switch on store instead on load.
This is the accompanying change for flutter/engine#8148 and it needs the engine PR to land first.
flutter/engine@403337e...b36068c git log 403337e..b36068c --no-merges --oneline b36068c Roll src/third_party/skia 05201fc7e77e..aefecad7c0d2 (5 commits) (flutter/engine#8176) b32d0ab Bugfix: Prevent crash when responding to a platform message after FlutterJNI detaches from native (#28651). (flutter/engine#8170) d9b2f09 Roll src/third_party/skia 512e38091c85..05201fc7e77e (10 commits) (flutter/engine#8173) 4b01d79 Add frame and target time metadata to vsync events and connect platform vsync events using flows. (flutter/engine#8172) f7a0922 [fuchsia] Remove deprecated libraries from snapshot (flutter/engine#8085) 09db84f Android Embedding PR 19: Add accessibility to new FlutterView. (flutter/engine#8109) 246f0e3 Add an allocator specific check to ensure that strings passed to the timeline are not heap allocated. (flutter/engine#8168) 7a6bb99 Roll src/third_party/skia feb720f746dc..512e38091c85 (11 commits) (flutter/engine#8169) 5825bda Roll src/third_party/dart 7d560f8385..7418238239 (61 commits) 66fdeb1 Add dump-shader-skp switch to help ShaderWarmUp (flutter/engine#8148) The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md If the roll is causing failures, please contact the current sheriff (jsimmons@google.com), and stop the roller if necessary.
This is the accompanying change for flutter/engine#8148 and it needs the engine PR to land first. For #813
Allow Flutter to automatically dump the skp that triggers new shader compilations. This is useful for writing custom ShaderWarmUp to reduce jank. By default, it's not enabled to reduce the overhead. This is only available in profile or debug build. Later, we can add service protocol support to pull the skp from the client to the host. Currently, it works fine for Android-based devices (including our urgent internal clients) where we can `adb shell` into the cache directory.
This reverts commit 0c6de52.
This reverts commit 0c6de52.
Allow Flutter to automatically dump the skp that triggers new shader compilations. This is useful for writing custom ShaderWarmUp to reduce jank. By default, it's not enabled to reduce the overhead. This is only available in profile or debug build.
Later, we can add service protocol support to pull the skp from the client to the host. Currently, it works fine for Android-based devices (including our urgent internal clients) where we can
adb shell
into the cache directory.