From cf85d16a4393a8acd8b27a131f7b9838d7223403 Mon Sep 17 00:00:00 2001 From: Jake Lynch Date: Wed, 2 Jul 2025 12:10:15 -0500 Subject: [PATCH] apply patch --- .../android/ReactCommon/JavaTurboModule.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/react-native/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp b/packages/react-native/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp index b36755ef4ee..20433eb7fe5 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp +++ b/packages/react-native/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp @@ -989,15 +989,18 @@ void JavaTurboModule::setEventEmitterCallback( *eventEmitterMap_[eventName].get()); }; - jvalue arg; - arg.l = JCxxCallbackImpl::newObjectCxxArgs([eventEmitterLookup = std::move( + // Patch from https://github.com/facebook/react-native/pull/51695 to fix https://github.com/facebook/react-native/issues/51628#issuecomment-2922391662 + auto callback = JCxxCallbackImpl::newObjectCxxArgs([eventEmitterLookup = std::move( eventEmitterLookup)]( folly::dynamic args) { auto eventName = args.at(0).asString(); auto eventArgs = args.size() > 1 ? args.at(1) : nullptr; eventEmitterLookup(eventName).emit(std::move(eventArgs)); - }).release(); - env->CallVoidMethod(instance, cachedMethodId, arg); -} + }); + jvalue args[1]; + args[0].l = callback.release(); + // CallVoidMethod is replaced with CallVoidMethodA as it's unsafe on 32bit and causes crashes + // https://github.com/facebook/react-native/issues/51628 + env->CallVoidMethodA(instance, cachedMethodId, args);} } // namespace facebook::react