Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[Impeller] Makes validation layers flag work for android #42625

Merged
merged 6 commits into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ allowed_hosts = [
]

deps = {
'src': 'https://github.com/flutter/buildroot.git' + '@' + '859e7ccc38f55f89dac8aea49367b7a4c1656490',
'src': 'https://github.com/flutter/buildroot.git' + '@' + 'fabb92f0ada787444ad0be22638c80a6d5927a2c',

# Fuchsia compatibility
#
Expand Down
22 changes: 22 additions & 0 deletions shell/platform/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import("//build/config/android/config.gni")
import("//build/toolchain/clang.gni")
import("//flutter/build/zip_bundle.gni")
import("//flutter/common/config.gni")
import("//flutter/impeller/tools/impeller.gni")
import("//flutter/shell/config.gni")
import("//flutter/shell/gpu/gpu.gni")
import("//flutter/shell/version/version.gni")
import("//flutter/vulkan/config.gni")

shell_gpu_configuration("android_gpu_configuration") {
enable_software = true
Expand Down Expand Up @@ -478,6 +480,26 @@ action("android_jar") {
":pom_libflutter",
]

if (enable_vulkan_validation_layers) {
assert(impeller_enable_vulkan)
deps += [ "//third_party/vulkan_validation_layers" ]
args += [
"--native_lib",
rebase_path("libVkLayer_khronos_validation.so",
root_build_dir,
root_build_dir),
]
if (current_cpu == "arm64") {
args += [
"--native_lib",
rebase_path("$android_libcpp_root/libs/arm64-v8a/libc++_shared.so",
root_build_dir),
]
} else {
assert(false, "Validation layers not supported for arch.")
}
}

if (flutter_runtime_mode == "profile") {
deps += [ "//flutter/shell/vmservice:vmservice_snapshot" ]
args += [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class FlutterLoader {
"io.flutter.embedding.android.OldGenHeapSize";
private static final String ENABLE_IMPELLER_META_DATA_KEY =
"io.flutter.embedding.android.EnableImpeller";
private static final String ENABLE_VULKAN_VALIDATION_META_DATA_KEY =
"io.flutter.embedding.android.EnableVulkanValidation";

/**
* Set whether leave or clean up the VM after the last shell shuts down. It can be set from app's
Expand Down Expand Up @@ -316,8 +318,13 @@ public void ensureInitializationComplete(

shellArgs.add("--prefetched-default-font-manager");

if (metaData != null && metaData.getBoolean(ENABLE_IMPELLER_META_DATA_KEY, false)) {
shellArgs.add("--enable-impeller");
if (metaData != null) {
if (metaData.getBoolean(ENABLE_IMPELLER_META_DATA_KEY, false)) {
shellArgs.add("--enable-impeller");
}
if (metaData.getBoolean(ENABLE_VULKAN_VALIDATION_META_DATA_KEY, false)) {
shellArgs.add("--enable-vulkan-validation");
}
}

final String leakVM = isLeakVM(metaData) ? "true" : "false";
Expand Down
1 change: 1 addition & 0 deletions shell/platform/fuchsia/flutter/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ assert(is_fuchsia)

import("//build/fuchsia/sdk.gni")
import("//flutter/common/config.gni")
import("//flutter/shell/config.gni")
import("//flutter/shell/gpu/gpu.gni")
import("//flutter/testing/testing.gni")
import("//flutter/tools/fuchsia/dart.gni")
Expand Down
2 changes: 1 addition & 1 deletion testing/scenario_app/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
org.gradle.jvmargs=-Xmx1536M
org.gradle.jvmargs=-Xmx2048M
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 this for?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was just running into it. I'm not 100% sure it caused by this change. My theory is that having those extra .so files in the flutter.jar file somehow requires more memory when the build is happening.

Copy link
Contributor

Choose a reason for hiding this comment

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

(this increases the JVM heap that gradle uses. It's probably fine to increase this)

android.useAndroidX=true
android.enableJetifier=true
android.builder.sdkDownload=false
9 changes: 4 additions & 5 deletions tools/gn
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ def to_command_line(gn_args):
def merge(key, value):
if isinstance(value, bool):
return '%s=%s' % (key, 'true' if value else 'false')
if isinstance(value, int):
return '%s=%d' % (key, value)
return '%s="%s"' % (key, value)

return [merge(x, y) for x, y in gn_args.items()]
Expand Down Expand Up @@ -548,11 +550,8 @@ def to_gn_args(args):
gn_args['use_fstack_protector'] = True

if args.enable_vulkan_validation_layers:
if args.target_os != 'fuchsia':
print(
'Vulkan validation layers are currently only supported on Fuchsia targets.'
)
sys.exit(1)
if args.target_os == 'android':
gn_args['android_api_level'] = 26
gn_args['enable_vulkan_validation_layers'] = True

# Enable pointer compression on 64-bit mobile targets. iOS is excluded due to
Expand Down
6 changes: 1 addition & 5 deletions vulkan/config.gni
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
# found in the LICENSE file.

declare_args() {
# Whether to include vulkan validation layers, if available.
Copy link
Member

Choose a reason for hiding this comment

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

Probably also useful to retain this comment when copying the arg to the new location.

Can this file be deleted?

Alternately, why not just leave the arg here and include this config.gni where it's needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved it back, that area of the code is fuchsia specific so I thought shell might make more sense. By name alone though it should be relevant.

#
# Currently these are only supported on Fuchsia, where by default they are
# disabled, to enable them pass `--enable-vulkan-validation-layers` to your
# gn args.
# Whether to include vulkan validation layers.
enable_vulkan_validation_layers = false
}