fix(android): forward ExecuTorch consumer ProGuard rules#1325
Conversation
There was a problem hiding this comment.
Thanks for contributing! The PR looks solid.
One blocking gap: the rules are scoped to org.pytorch.executorch.**, but RNE resolves its own class by literal descriptor from C++ (ETInstallerModule.h:18 → Lcom/swmansion/rnexecutorch/ETInstaller;). ETInstaller has @DoNotStrip on the method, not the class, so R8 can still rename the class — which is the failure shape your stack trace shows (ETInstaller.<init>). See the inline comment.
Also: could you paste the real logcat? System.loadLibrary doesn't throw ClassNotFoundException, and ETInstaller.init catches only UnsatisfiedLinkError, so the trace in the description doesn't match the diagnosis. Helps confirm which rule is load-bearing.
f5a90a9 to
9573152
Compare
|
Thank you very much for the thorough review and detailed explanations. I’ve applied the requested changes! We’re using React Native ExecuTorch successfully in our app, so thank you as well for building and maintaining this library. Here is the raw logcat from a minified release build without the consumer rules, reproduced on a physical Galaxy S20 FE: |
|
Thanks for the logcat — it makes the mechanism clear. Worth noting for the record: |
msluszniak
left a comment
There was a problem hiding this comment.
I tested the fix on minified build with our llm demo app, and the issue reproduced clearly. Without the fix, I got the same crash. After applying the fix, it worked correctly. Btw, can you disclose the name of the app you are working on? Our team is very curious to see how React Native ExecuTorch is used in apps :))
|
Thank you so much for reviewing and testing the fix! Sure thing — our app is Lita Book. We are using kokoro at book reader. it’s one of several projects I’m building with my teammates. We’re continuing to improve it and gradually grow the user base :) |
|
Thank you for your response, we'll look at Lita Book for sure :)) |
Description
Fixes an Android release crash caused by R8 removing ExecuTorch classes that are accessed during JNI initialization.
at minified release builds without the consumer rules, the app crashes during
ETInstallerinitialization:This PR ports the upstream rules and registers them through
consumerProguardFilesThe first two rules ared covered with RN's own consumer rules, but are intentionally retained to keep the upstream ExecuTorch rule block intact. The rule that fixes the observed
Modulecrash is:Introduces a breaking change?
Type of change
Tested on
Testing instructions
Screenshots
Related issues
Checklist
Additional notes
Android-only; iOS does not use R8. tested on a android physical device(galaxy s20 FE)
The upstream ExecuTorch rules are copied without semantic changes.