Repository navigation
Conversation
|
|
…ndroid Patch 029: Fix JNI copy-paste bug where HermesSamplingProfiler.disable() was mapped to ::enable instead of ::disable, preventing the profiler from ever being properly stopped. Patch 030: Add doLast hook to unzipHermes Gradle task that replaces pthread_kill with tgkill syscall in SamplingProfilerPosix.cpp. On Android (Bionic), pthread_kill aborts on invalid pthread_t instead of returning ESRCH. The Gradle hook approach ensures the fix survives Hermes source re-extraction during builds. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
As its patch of hermes its not trivial to checkout it and test it in dev, as I needed to do extra steps to do it, it wont work without those steps, so Id like to trigger staging build and than we can test it from there ? I attach instructions how to test it with dev locally but I hope we can produce build instead How to test locally on dev (workaround) Building from source doesn't work locally due to a pre-existing react-native-worklets linker error (unrelated to our patches). The prebuilt artifacts don't include our patches yet. So we need to build Hermes Step 1: Build the patched libhermes.so Set forceBuildFromSource=true in Mobile-Expensify/Android/gradle.properties: Run yarn android --local. It will fail on the worklets linker step, but Hermes will have been compiled successfully before that. The patched libhermes.so will be at: Set forceBuildFromSource back to false. Step 2: Build a working HybridApp APK Temporarily move our patches aside so the hash matches the existing prebuilt: Build normally: Restore the patches: Step 3: Swap libhermes.so in the APK APK=Mobile-Expensify/Android/build/outputs/apk/debug/Expensify-debug.apk Copy APKcp "$APK" /tmp/hybrid-patched.apk Remove old signingzip -d /tmp/hybrid-patched.apk "META-INF/*" Replace libhermes.so (must be stored uncompressed)mkdir -p /tmp/lib/arm64-v8a Zipalign then sign (order matters — sign AFTER align)$ZIPALIGN -p -f 4 /tmp/hybrid-patched.apk /tmp/hybrid-patched-aligned.apk If you don't have a debug keystore, generate one: Step 4: Install on device/emulator adb install /tmp/hybrid-patched-aligned.apk Then start Metro with yarn start and test. Note: This workaround is only needed for local dev testing. CI/staging builds might work automatically — the PatchedArtifacts system will detect the new patch hash, build from source in CI (which has a clean |
|
@jasperhuangg Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6fb0a82177
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| } | ||
| } | ||
| into(hermesDir) | ||
| + doLast { |
There was a problem hiding this comment.
Ensure Hermes source patch runs on up-to-date builds
Attaching the fix only inside doLast means it executes only when unzipHermes actually runs; Gradle skips task actions when a task is UP-TO-DATE, so cached workspaces/CI agents that already extracted Hermes before this change can keep using an unpatched SamplingProfilerPosix.cpp and still hit the Android SIGABRT path. This should either force rerun/invalidated outputs for unzipHermes or fail fast if the expected replacements are not present.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
I got this input:
In practice, the risk is low because:
- CI always starts clean →
unzipHermesalways runs npm installfreshens node_modules → extraction happens- The
if (!content.contains("currentTid_"))guard makes it idempotent when it does run
|
🚧 @rlinoz has triggered a test Expensify/App build. You can view the workflow run here. |
This comment has been minimized.
This comment has been minimized.
|
🚧 @rlinoz has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
I think same issue , so maybe you can execute it without the rock cache |
|
oh I did, but let's run it again |
|
🚧 @rlinoz has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
Build is failing with: Let's try to merge main @elirangoshen |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
done |
|
🚧 @Julesssss has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
rlinoz
left a comment
There was a problem hiding this comment.
Tests well for me, is there an upstream patch too?
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safari |
|
🚧 @Julesssss has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
No, I will make one |
Lets use this issue |
|
🚀 Deployed to staging by https://github.com/Julesssss in version: 9.3.41-0 🚀
Bundle Size Analysis (Sentry): |
Sure, can you assign it to me ? |
|
🚀 Deployed to production by https://github.com/cristipaval in version: 9.3.41-4 🚀
|
Explanation of Change
Fixes Android
SIGABRTcrash (invalidpthread_tpassed topthread_killinhermes-samplingthread) that occurs when Sentry Hermes profiling is enabled (profilesSampleRate> 0).Two root causes were identified and fixed via React Native patches:
Patch 030 — JNI copy-paste bug fix
In
HermesSamplingProfiler.cpp, the JNI disable method was incorrectly mapped toHermesSamplingProfiler::enableinstead ofHermesSamplingProfiler::disable. When Sentry calleddisable()to stop profiling, it actually calledenable()again, corrupting the sampling thread state.Patch 031 — Replace
pthread_killwithtgkillon AndroidOn Android (Bionic libc), pthread_kill with an invalid pthread_t (e.g., thread has exited) calls abort() instead of returning ESRCH like glibc. The Hermes sampling profiler sends SIGPROF via pthread_kill at ~100Hz. If a runtime thread exits while profiling is active, the stale pthread_t triggers the SIGABRT.
This patch replaces pthread_kill with the tgkill syscall on Android, which safely returns ESRCH for dead threads.
The patch is applied via a doLast Gradle hook on unzipHermes because that task downloads fresh Hermes source, overwriting any direct source patches.
Fixed Issues
$ #75036
$ #85860
Tests
[x] Verify that no errors appear in the JS console
Offline tests
N/A — this is a native-level fix that doesn't affect offline behavior.
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari