Skip to content
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

[Impeller] turned on validations for all debug builds #45350

Merged
merged 5 commits into from
Sep 1, 2023

Conversation

gaaclarke
Copy link
Member

@gaaclarke gaaclarke commented Aug 31, 2023

fixes flutter/flutter#133794

This adds the following shared libraries to the flutter.jar for debug builds on arm64:

lib/arm64-v8a/libVkLayer_khronos_validation.so
lib/arm64-v8a/libc++_shared.so

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@gaaclarke gaaclarke force-pushed the validation-layers-for-everyone branch 2 times, most recently from db335be to 639425d Compare August 31, 2023 22:43
@gaaclarke gaaclarke force-pushed the validation-layers-for-everyone branch from 639425d to 602d4d6 Compare August 31, 2023 23:01
@gaaclarke gaaclarke marked this pull request as ready for review August 31, 2023 23:05
Copy link
Member

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if licensing is good.

We can also run a debug build smoke test (later) in the devicelab to make sure we're not hitting validation errors.

@flutter-dashboard
Copy link

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 (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@gaaclarke
Copy link
Member Author

gaaclarke commented Aug 31, 2023

This runs fine locally but fails fails to build on CI. Presumably the api level is coming from the buildroot (https://github.com/flutter/buildroot/blob/6b0243e97d94836767ea8b94a477d7d15ee3bb91/build/config/android/config.gni#L47).

The API guard isn't even apropos for us since we don't load the dynamic library unless we are using the vulkan backend (and thus are on a platform that supports vulkan, ie >= 23).

I'll have to find a way to override this API setting, probably editing the buildroot tomorrow.

if (enable_vulkan_validation_layers) {
if (enable_vulkan_validation_layers ||
(impeller_enable_vulkan && current_cpu == "arm64" &&
flutter_runtime_mode == "debug")) {
assert(impeller_enable_vulkan)
deps += [ "//third_party/vulkan_validation_layers" ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between this and //third_party/vulkan-deps/vulkan-validation-layers ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gaaclarke
Copy link
Member Author

@zanderso @jonahwilliams actually this may not be possible to implement because of limitations in GN. So the problem is that we need android >= 23 to build the validation layers. The engine supports android 22. It's not a problem at runtime because we can check the android version before loading the dylib.

The way we get around this build problem today is that if you are building a local engine with validation layers enabled we globally set the android api level to 26. We can't do the same trick when building the engine for everyone. There doesn't seem to be a way to have different android api levels for different targets in GN. I'll verify this.

@gaaclarke
Copy link
Member Author

The other option would be to split our build process into multiple ninja invocations then bundle everything together. I'm not sure how we'd do that, but at face value sounds involved.

@jonahwilliams
Copy link
Member

I think that if this is too more work, instead we should just point folks and the triagers to https://developer.android.com/ndk/guides/graphics/validation-layer

@zanderso
Copy link
Member

zanderso commented Sep 1, 2023

I'd like to study this a bit to see if I can make a suggestion. I can sometimes bend GN to my will.

@gaaclarke
Copy link
Member Author

I'd like to study this a bit to see if I can make a suggestion. I can sometimes bend GN to my will.

Here is the override we currently use for reference:

engine/tools/gn

Line 652 in 069354f

gn_args['android_api_level'] = 26

Our options as I see them:

  1. Bump the engine to only support android >= 23
  2. Split our build into multiple GN builds and rely on a build script that runs ninja twice and combines the result
  3. (forbidden) package prebuilt validation layers
  4. Rely on showing users how to inject the validation layers. Maybe there is something we can do to grease the wheels here? A script that modifies an apk?

@gaaclarke gaaclarke added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 1, 2023
@gaaclarke
Copy link
Member Author

gaaclarke commented Sep 1, 2023

Heads up I'm putting this into the autosubmit queue. I've been in contact with the reviewers about changes we made since approval. I just wanted to notify everyone since it has technically changed.

Copy link
Member

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still LGTM, thanks @gaaclarke and @zanderso !

@auto-submit auto-submit bot merged commit b6224e2 into flutter:main Sep 1, 2023
27 checks passed
@@ -646,7 +646,9 @@ def to_gn_args(args):
if args.unoptimized and args.target_os == 'android' and args.android_cpu == 'arm64':
enable_vulkan_validation = True

if enable_vulkan_validation:
if enable_vulkan_validation or (args.enable_impeller_vulkan and
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the changes to the GN build for the validation layers .so, does the API level for the whole build still need to be bumped up to 26 down on line 654?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, not necessary anymore. I can rip it out.

engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 2, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Sep 2, 2023
…sions) (#133924)

Manual roll requested by zra@google.com

flutter/engine@489c399...e496eec

2023-09-02 skia-flutter-autoroll@skia.org Roll Skia from 2d8849f9f0cc to 15f77147a3ec (1 revision) (flutter/engine#45414)
2023-09-02 skia-flutter-autoroll@skia.org Roll Fuchsia Mac SDK from OF4TS05qlWCjukWw6... to MesZPNdj-uw8VdCyV... (flutter/engine#45413)
2023-09-02 dkwingsmt@users.noreply.github.com Remove --disable-service-auth-codes (flutter/engine#45356)
2023-09-02 bdero@google.com [Impeller] Import cstring for memcpy. (flutter/engine#45408)
2023-09-02 skia-flutter-autoroll@skia.org Roll Dart SDK from cdf1ce0c6d7e to a5c7102af509 (1 revision) (flutter/engine#45412)
2023-09-02 skia-flutter-autoroll@skia.org Roll ANGLE from 179bd7762ffa to ebf1e7163216 (1 revision) (flutter/engine#45411)
2023-09-02 dkwingsmt@users.noreply.github.com Remove deprecated MOCK_METHODx calls (flutter/engine#45307)
2023-09-02 jonahwilliams@google.com [Impeller] Better demonstrate blur and draw picture? (flutter/engine#45388)
2023-09-02 jonahwilliams@google.com [Impeller] Make paths externally immutable, update all tests to use PathBuilder to create Path. (flutter/engine#45393)
2023-09-02 skia-flutter-autoroll@skia.org Roll ANGLE from 962fdf7b7882 to 179bd7762ffa (1 revision) (flutter/engine#45409)
2023-09-02 flar@google.com Cull the RTree bounds when they are forwarded in DrawDisplayList (flutter/engine#45358)
2023-09-02 skia-flutter-autoroll@skia.org Roll Skia from fedff79a6afc to 2d8849f9f0cc (3 revisions) (flutter/engine#45407)
2023-09-02 jonahwilliams@google.com [impeller] premultiply vertices colors. (flutter/engine#45406)
2023-09-01 skia-flutter-autoroll@skia.org Roll ANGLE from 6a09e41ce6ea to 962fdf7b7882 (224 revisions) (flutter/engine#45400)
2023-09-01 skia-flutter-autoroll@skia.org Roll Skia from 22ae23891e8e to fedff79a6afc (1 revision) (flutter/engine#45405)
2023-09-01 30870216+gaaclarke@users.noreply.github.com [Impeller] turned on validations for all debug builds (flutter/engine#45350)
2023-09-01 skia-flutter-autoroll@skia.org Roll Fuchsia Mac SDK from sk7JBGzW1Jw10Wy-T... to OF4TS05qlWCjukWw6... (flutter/engine#45403)
2023-09-01 skia-flutter-autoroll@skia.org Roll Skia from 2c0405489966 to 22ae23891e8e (1 revision) (flutter/engine#45402)
2023-09-01 737941+loic-sharma@users.noreply.github.com [Windows] Update vsync on raster thread (flutter/engine#45310)
2023-09-01 skia-flutter-autoroll@skia.org Roll Dart SDK from a2ea759c16cc to cdf1ce0c6d7e (1 revision) (flutter/engine#45397)
2023-09-01 skia-flutter-autoroll@skia.org Roll Skia from f3f6c733c7e6 to 2c0405489966 (1 revision) (flutter/engine#45396)
2023-09-01 skia-flutter-autoroll@skia.org Roll Skia from 02fa14799c6c to f3f6c733c7e6 (1 revision) (flutter/engine#45394)
2023-09-01 skia-flutter-autoroll@skia.org Roll Skia from d5d3b0d4ee77 to 02fa14799c6c (2 revisions) (flutter/engine#45392)
2023-09-01 41930132+hellohuanlin@users.noreply.github.com [ios][ios17][text_input]fix text input system highlight in iOS 17 Beta 7 with firstRectForRange (flutter/engine#45303)
2023-09-01 skia-flutter-autoroll@skia.org Roll Skia from d6266ef14a7e to d5d3b0d4ee77 (2 revisions) (flutter/engine#45389)
2023-09-01 skia-flutter-autoroll@skia.org Roll Dart SDK from 0c121a6431cc to a2ea759c16cc (1 revision) (flutter/engine#45384)

Also rolling transitive DEPS:
  fuchsia/sdk/core/mac-amd64 from sk7JBGzW1Jw1 to MesZPNdj-uw8

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,rmistry@google.com,zra@google.com 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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
auto-submit bot pushed a commit that referenced this pull request Sep 6, 2023
@gbak
Copy link

gbak commented Jul 19, 2024

@gaaclarke is there a way to exclude this library from the Android build? The Vulkan library doubles the size of our debug apks. I've seen the suggestion of a jniLibs exclude, but didn't know if that would have any adverse behaviors.
excludes.add("**/libVkLayer_khronos_validation.so")

@gaaclarke
Copy link
Member Author

@gaaclarke is there a way to exclude this library from the Android build? The Vulkan library doubles the size of our debug apks. I've seen the suggestion of a jniLibs exclude, but didn't know if that would have any adverse behaviors.
excludes.add("**/libVkLayer_khronos_validation.so")

Yes, you can just remove it. I'm not familiar with android build systems so I'm not sure if that will invalidate your codesigning. Otherwise, there should be some gradle command to strip it. I believe that if you remove the dynamic libraries that flutter will still function correctly, it should just print out an error message that it couldn't find the validation layers. If you find that isn't the case I'd file a bug for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App platform-android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Impeller] Make Vulkan validation on Android for end users self-serve.
4 participants