Repository navigation
build: raise the default minSdk to 24 - #2135
Draft
edusperoni wants to merge 1 commit into
Draft
edusperoni wants to merge 1 commit into
edusperoni wants to merge 1 commit into
Conversation
Google Play services and Firebase libraries require minSdk 24, so most apps already declare it. NS_DEFAULT_MIN_SDK_VERSION, which the runtime library and every app's build.gradle default to, goes from 21 to 24, as do the minSdk/ndkApiLevel entries in package.json's version_info. With 24 as the floor: - Optimized links pass -Wl,--pack-dyn-relocs=android (the loader reads the packed format from API 23); the dynamic relocation table shrinks from 1,098,144 to 153,106 bytes on arm64-v8a. clang also stops emitting the SysV .hash section next to .gnu.hash. - AChoreographer_getInstance/postFrameCallback(Delayed) are linked directly instead of through dlsym. Only the API 29 64-bit variants are still resolved at run time. - The android.view.Choreographer fallback (com.tns.FrameCallbacks), its JNI entry point and the debug-only __setFrameCallbackImpl hook that tested it are removed. - The SDK_INT >= 24 gates on default-method handling (InterfaceProxyHandler, DexFactory, Runtime.getDefaultMethodNames) and the pre-24 DexPathList reflection behind injectDexIntoClassLoader are removed; addDexPath is always available. Behavior on API 24+ devices is unchanged. Apps that declare a minSdk of 21-23 now fail the manifest merge and must raise it; apps that declare none become minSdk 24.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Since July, Google Play services and Firebase libraries require minSdk 24, so most apps already declare it. This PR raises the runtime's default minSdk to 24 as well and removes the code that only existed for API 21–23.
Current behavior.
NS_DEFAULT_MIN_SDK_VERSION=21sets the minSdk of the runtime library and is the default for every app'sbuild.gradle.package.jsonreportsversion_info.minSdk/ndkApiLevelas 21. The runtime carries fallbacks for API 21–23:android.view.Choreographerframe-callback bridge (com.tns.FrameCallbacks)dlsymlookup ofAChoreographerSDK_INT >= 24gates around default-method handlingDexPathListreflection in place ofBaseDexClassLoader.addDexPathNew behavior.
NS_DEFAULT_MIN_SDK_VERSION=24(test-app/gradle.properties, which ships to apps).version_info.minSdkandndkApiLevelinpackage.jsonare now 24.-Wl,--pack-dyn-relocs=android, Android's packed relocation format, which the loader reads from API 23. At API 23+, clang also links with--hash-style=gnu, which drops the SysV.hashsection.FrameCallbacks.cpplinksAChoreographer_getInstance,AChoreographer_postFrameCallbackandAChoreographer_postFrameCallbackDelayeddirectly. The API 29*64variants are still resolved withdlsymand preferred when present, exactly as before. The Java fallback (FrameCallbacks.java), its JNI entry point, and the debug-only__setFrameCallbackImplhook plus the specs that drove it are removed.SDK_INT >= 24gates inInterfaceProxyHandler,DexFactory.generateDexandRuntime.getDefaultMethodNamesare removed. So is the pre-24appendDexElementsreflection, sinceaddDexPathis always available now.On API 24+ devices, every removed branch was already the one not taken, so runtime behavior there is unchanged.
What apps see
app.gradleor the manifest) now fail the manifest merge and must raise minSdk to 24. Verified by building the test app with-PminSdk=23:tools:overrideLibrarypast this is unsupported.libNativeScript.sowill not load below 24: it has packed relocations and only a GNU hash table, which API 21–22 cannot read, and it importsAChoreographer_*symbols, which API 23 lacks.useLegacyPackagingnow defaults to false, so.sofiles are stored uncompressed and page-aligned in the APK and are loaded from it in place. They are no longer extracted tonativeLibraryDir.nativeLibraryDirthrough but never reads files from it, and the suite passes this way.nativeLibraryDirwould needpackaging { jniLibs { useLegacyPackaging = true } }.Size (optimized release,
-PoptimizedRelWithDebInfo,llvm-strip --strip-all, NDK r29).so.rela.dyn/.rel.dyn)llvm-readelf -don the new arm64 library showsANDROID_RELA/ANDROID_RELASZandGNU_HASHonly, with noHASH.Performance
Measured on an arm64 phone (Samsung SM-G780G, Android 13), optimized release APKs. Base is current
main(minSdk 21); new is this branch (minSdk 24).Library load.
dlopen(libNativeScript.so, RTLD_NOW)of the stripped library, each in a fresh process, 20 interleaved runs (1 warm-up round dropped):The packed format changes how relocations are encoded, not how many there are, so load time is unchanged. The win is size.
Cold start.
am start -WTotalTime afteram force-stop. 3 interleaved install blocks per build, each with 1 dropped launch and 5 measured (n=15). The app runs a trivial script at startup.JNI bridge (
debug.ns.jnibench, 2 interleaved blocks × 2 runs, compared run against matching run because the phone alternates between two clock states; median of the 4 per-run deltas):static.noop()static.add(int,int)instance.getInt()instance.echo(String)field.get intcallback.twoInts(int,int)Per-call cost is unchanged. The callback and contention rows swing by tens of percent between clock states in either build.
Follow-ups, not in this PR
test-app/runtime/CMakeLists.txtwe pass-mstackrealignourselves on every ABI. Its only purpose is an x86 bug below API 24, so at minSdk 24 it is dead. The companion PR that keeps the NDK default flags already stops passing it, and leaves it to the NDK toolchain, which only adds it for x86 below API 24. Once both PRs land, x86 loses it too. This PR does not touch it, so the two stay independent.isDesugared()expectations and theSDK_INT < 24early returns intestInterfaceDefaultMethodOverrides.js,testInterfaceProxies.js,testAppModuleBindings.js,testInterfaceExtendClasses.js,testRuntimeGenerationReport.jsandtestRequestAnimationFrame.js. They are left as they are, so they can be pruned separately.Does your commit message include the wording below to reference a specific issue in this repo?
No.
Related Pull Requests
main.Does your pull request have unit tests?
The existing frame-callback specs cover the remaining native path. The two specs that forced the removed Java path are gone. Verification:
./gradlew runtestsAndVerifyResults -Pabis=arm64-v8a) on an arm64 API 36 emulator: 1771 specs, 0 failures. That is 1773 on main minus the two removed Java-path specs.-PminSdk=23fails as quoted above.dlopened in a 32-bit process on the same phone.