[r8-obfuscation] Enable R8 JNI name obfuscation for NativeAOT - #12634
[r8-obfuscation] Enable R8 JNI name obfuscation for NativeAOT#12634simonrozsival wants to merge 4 commits into
Conversation
a7bff4c to
a8fff0b
Compare
|
/azp run |
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
|
/azp run |
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
|
/azp run |
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
|
/azp run |
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
4c591ed to
80dbc97
Compare
80dbc97 to
2099dc9
Compare
2099dc9 to
07eaa87
Compare
07eaa87 to
7c2485f
Compare
cbb6df2 to
f547135
Compare
f547135 to
ec9422a
Compare
ec9422a to
c544a34
Compare
c544a34 to
1912f90
Compare
|
Why is this rewriting necessary? Can't we tell R8 not to rename things we need? There must be an escape hatch for reflection. What we're doing is reflection. Bugs in rewritten assemblies pretty much always land on runtime team's plate to troubleshoot. dotnet/maui#37782 (comment) was the most recent one and that one was extra annoying because people who knew about the rewriting (they edited the rewriter files in the past) were on the thread and did not say there was a rewrite. I'm not a big fan of these approaches. |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
NativeAOT correctly removes an unreferenced managed peer from the final R8 reachability set. Keep the test peer live through MainActivity and assert its exact reachability provenance before checking the final mapping. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The generated ACW keep file is intentionally excluded from final R8, so NativeAOT correctly removed the unreferenced library peer. Reference it from the app and assert its reachability provenance before validating the public mapping. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1912f90 to
4226ed9
Compare
|
@MichalStrehovsky we are looking into ways to support Google's new requirements on app optimizations (https://android-developers.googleblog.com/2026/08/app-quality-memory-optimization-secure-onboarding.html). We're currently using a |
|
@simonrozsival Michal's question was whether you can meet the requirement by generating fine-grained |
|
I'm trying this out as an alternative, but we will have to submit an app to Google Play to test the full end-to-end: |
Related to #12535
Depends on #12632
Layer 6 of 6 and the top of the replacement stack for draft PR #12575. Extends the shared two-pass R8 JNI name-obfuscation pipeline to NativeAOT, including incremental pre-ILC assembly rewriting, conservative JNI class/member reachability, seed-compatible final keep rules, and prebuilt runtime JNI startup keeps.
Testing:
Xamarin.Android.Build.Tasks.csprojbuilds successfully.Xamarin.Android.Build.Tests.csprojbuilds successfully.TypeMapAssemblyGeneratorTests: 121/121 passed, including owner-specific JNI method-name FieldRVA coverage.NETSDK1147: To build this project, the following workloads must be installed: android; no unrelated workload was installed.