Skip to content

Commit

Permalink
Let react_native_assert really abort the app
Browse files Browse the repository at this point in the history
Summary:
Fixed a bug in `react_native_assert` that was not effectively letting the app
call `abort()`. The app was actually printing on log twice.
Ref: https://developer.android.com/ndk/reference/group/logging#__android_log_assert

Changelog:
[Android] [Changed] - Let react_native_assert really abort the app

Reviewed By: JoshuaGross

Differential Revision: D32204080

fbshipit-source-id: ca16c50aaf4e41a2318277c233be0e944b2ad8f1
  • Loading branch information
cortinico authored and facebook-github-bot committed Nov 11, 2021
1 parent 1814649 commit 2ae06df
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ReactCommon/react/debug/react_native_assert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extern "C" void react_native_assert_fail(
const char *file,
int line,
const char *expr) {
// Print as an error so it shows up in logcat before crash....
// Print as an error so it shows up in logcat before crash...
__android_log_print(
ANDROID_LOG_ERROR,
"ReactNative",
Expand All @@ -31,9 +31,9 @@ extern "C" void react_native_assert_fail(
line,
func,
expr);
// Print as a fatal so it crashes and shows up in uploaded logs
__android_log_print(
ANDROID_LOG_FATAL,
// ...and trigger an abort so it crashes and shows up in uploaded logs.
__android_log_assert(
nullptr,
"ReactNative",
"%s:%d: function %s: assertion failed (%s)",
file,
Expand Down

0 comments on commit 2ae06df

Please sign in to comment.