Skip to content

Commit

Permalink
Fix TS and initialization order for executeUIRuntimeSync. (#5516)
Browse files Browse the repository at this point in the history
## Summary

Minor changes to #4300.

## Test plan

🚀
  • Loading branch information
tjzel authored Dec 21, 2023
1 parent dfa97c4 commit f5c312a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
5 changes: 4 additions & 1 deletion Common/cpp/ReanimatedRuntime/WorkletRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ WorkletRuntime::WorkletRuntime(
}

std::unique_lock<std::recursive_mutex> WorkletRuntime::lock() {
assert(supportsLocking_ && "Runtime doesn't support locking");
assert(
supportsLocking_ &&
("[Reanimated] Runtime \"" + name_ + "\" doesn't support locking.")
.c_str());
return std::unique_lock<std::recursive_mutex>(runtimeMutex_);
}

Expand Down
2 changes: 1 addition & 1 deletion Common/cpp/ReanimatedRuntime/WorkletRuntime.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ class WorkletRuntime : public jsi::HostObject,
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &rt) override;

private:
std::recursive_mutex runtimeMutex_;
const std::shared_ptr<jsi::Runtime> runtime_;
const std::string name_;
std::shared_ptr<AsyncQueue> queue_;
std::recursive_mutex runtimeMutex_;
bool supportsLocking_;
};

Expand Down
8 changes: 4 additions & 4 deletions src/reanimated2/initializers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ const SHOULD_BE_USE_WEB = shouldBeUseWeb();
const IS_CHROME_DEBUGGER = isChromeDebugger();

// callGuard is only used with debug builds
export function callGuardDEV<T extends Array<unknown>, U extends void>(
fn: (...args: T) => U,
...args: T
): void {
export function callGuardDEV<Args extends unknown[], ReturnValue>(
fn: (...args: Args) => ReturnValue,
...args: Args
): ReturnValue | void {
'worklet';
try {
return fn(...args);
Expand Down
4 changes: 2 additions & 2 deletions src/reanimated2/threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ export function executeOnUIRuntimeSync<Args extends unknown[], ReturnValue>(
return NativeReanimatedModule.executeOnUIRuntimeSync(
makeShareableCloneRecursive(() => {
'worklet';
const ret = worklet(...args);
return makeShareableCloneOnUIRecursive(ret);
const result = worklet(...args);
return makeShareableCloneOnUIRecursive(result);
})
);
};
Expand Down

0 comments on commit f5c312a

Please sign in to comment.