Skip to content

Commit 4649770

Browse files
authored
fix(Worklets): strip RN Runtime assertions only for other runtimes (#8531)
## Summary After the changes done in #8471 it turned out that in Bundle Mode there were redundant checks for cpp version on Worklet Runtimes and also freezing Serializables on Worklet Runtimes. Check for the cpp version started to crash the runtime (previously it was silently failing) while the freezing could in some circumstances break the logic of Mutables. ## Test plan Run the app in Bundle Mode and see it's no longer crashing.
1 parent bc52bf3 commit 4649770

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

packages/react-native-worklets/src/WorkletsModule/NativeWorklets.native.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class NativeWorklets implements IWorkletsModule {
3333
See https://docs.swmansion.com/react-native-worklets/docs/guides/troubleshooting#native-part-of-worklets-doesnt-seem-to-be-initialized for more details.`
3434
);
3535
}
36-
if (__DEV__) {
36+
if (__DEV__ && globalThis.__RUNTIME_KIND === RuntimeKind.ReactNative) {
3737
checkCppVersion();
3838
}
3939
this.#workletsModuleProxy = global.__workletsModuleProxy;

packages/react-native-worklets/src/memory/serializable.native.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { registerWorkletStackDetails } from '../debug/errors';
44
import { jsVersion } from '../debug/jsVersion';
55
import { logger } from '../debug/logger';
66
import { WorkletsError } from '../debug/WorkletsError';
7+
import { RuntimeKind } from '../runtimeKind';
78
import type { WorkletFunction, WorkletImport } from '../types';
89
import { isWorkletFunction } from '../workletFunction';
910
import { WorkletsModule } from '../WorkletsModule/NativeWorklets';
@@ -650,7 +651,7 @@ function isRemoteFunction<TValue>(value: {
650651
* should use shared values instead.
651652
*/
652653
function freezeObjectInDev<TValue extends object>(value: TValue) {
653-
if (!__DEV__) {
654+
if (!__DEV__ || globalThis.__RUNTIME_KIND !== RuntimeKind.ReactNative) {
654655
return;
655656
}
656657
Object.entries(value).forEach(([key, element]) => {

0 commit comments

Comments
 (0)