From fac857dd313efe15098764b60ae6a5958be4304a Mon Sep 17 00:00:00 2001 From: Egor Pasko Date: Thu, 10 Jun 2021 14:17:34 +0200 Subject: Bump x86 WebView zygote reservation size to 190MiB The current 130MiB is not sufficient for the latest Chrome x86 dev build of stripped native library. Official ARM library is around 59 MiB (on disk). This flavor is slower to build and is less convenient to test with. Keep the 32bit arm reservation size unchanged, it is sufficient and allows growth. Bug: 184808875 Test: Manual: start a "release" build of Chrome/x86 (but not "official"), observe that with the change Chrome can mmap(MAP_FIXED) all the segments of the native library into the region successfully Change-Id: I00507169eafbdcfc4d413bb9c76188e179ca0c0e --- core/java/android/webkit/WebViewLibraryLoader.java | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'core/java/android/webkit/WebViewLibraryLoader.java') diff --git a/core/java/android/webkit/WebViewLibraryLoader.java b/core/java/android/webkit/WebViewLibraryLoader.java index be49fc434c79..91412d7e8631 100644 --- a/core/java/android/webkit/WebViewLibraryLoader.java +++ b/core/java/android/webkit/WebViewLibraryLoader.java @@ -178,12 +178,23 @@ public class WebViewLibraryLoader { */ static void reserveAddressSpaceInZygote() { System.loadLibrary("webviewchromium_loader"); - boolean is64Bit = VMRuntime.getRuntime().is64Bit(); - // On 64-bit address space is really cheap and we can reserve 1GB which is plenty. - // On 32-bit it's fairly scarce and we should keep it to a realistic number that - // permits some future growth but doesn't hog space: we use 130MB which is roughly - // what was calculated on older OS versions in practice. - long addressSpaceToReserve = is64Bit ? 1 * 1024 * 1024 * 1024 : 130 * 1024 * 1024; + long addressSpaceToReserve; + if (VMRuntime.getRuntime().is64Bit()) { + // On 64-bit address space is really cheap and we can reserve 1GB which is plenty. + addressSpaceToReserve = 1 * 1024 * 1024 * 1024; + } else if (VMRuntime.getRuntime().vmInstructionSet().equals("arm")) { + // On 32-bit the address space is fairly scarce, hence we should keep it to a realistic + // number that permits some future growth but doesn't hog space. For ARM we use 130MB + // which is roughly what was calculated on older OS versions. The size has been + // growing gradually, but a few efforts have offset it back to the size close to the + // original. + addressSpaceToReserve = 130 * 1024 * 1024; + } else { + // The number below was obtained for a binary used for x86 emulators, allowing some + // natural growth. + addressSpaceToReserve = 190 * 1024 * 1024; + } + sAddressSpaceReserved = nativeReserveAddressSpace(addressSpaceToReserve); if (sAddressSpaceReserved) { -- cgit v1.2.3