Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@ AnimatedSensorModule::AnimatedSensorModule(const PlatformDepMethodsHolder &platf
platformUnregisterSensorFunction_(platformDepMethodsHolder.unregisterSensor) {}

jsi::Value AnimatedSensorModule::registerSensor(
jsi::Runtime &rt,
jsi::Runtime &rnRuntime,
const std::shared_ptr<WorkletRuntime> &uiWorkletRuntime,
const jsi::Value &sensorTypeValue,
const jsi::Value &interval,
const jsi::Value &iosReferenceFrame,
const jsi::Value &sensorDataHandler) {
SensorType sensorType = static_cast<SensorType>(sensorTypeValue.asNumber());

auto serializableHandler = extractSerializableOrThrow<SerializableWorklet>(
rt, sensorDataHandler, "[Reanimated] Sensor event handler must be a worklet.");
auto serializableHandler = extractSerializable(
rnRuntime,
sensorDataHandler,
"[Reanimated] Sensor event handler must be a worklet.",
Serializable::ValueType::WorkletType);

int sensorId = platformRegisterSensorFunction_(
static_cast<int>(sensorType),
Expand All @@ -33,7 +36,7 @@ jsi::Value AnimatedSensorModule::registerSensor(
return;
}

jsi::Runtime &uiRuntime = uiWorkletRuntime->getJSIRuntime();
jsi::Runtime &uiRuntime = getJSIRuntimeFromWorkletRuntime(uiWorkletRuntime);
jsi::Object value(uiRuntime);
if (sensorType == SensorType::ROTATION_VECTOR) {
// TODO: timestamp should be provided by the platform implementation
Expand All @@ -53,7 +56,7 @@ jsi::Value AnimatedSensorModule::registerSensor(
}
value.setProperty(uiRuntime, "interfaceOrientation", orientationDegrees);

uiWorkletRuntime->runSync(serializableHandler, value);
runSyncOnRuntime(uiWorkletRuntime, serializableHandler, jsi::Value(uiRuntime, value));
});
if (sensorId != -1) {
sensorsIds_.insert(sensorId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

#include <reanimated/Tools/PlatformDepMethodsHolder.h>

#include <worklets/SharedItems/Serializable.h>
#include <worklets/WorkletRuntime/WorkletRuntime.h>
#include <worklets/Compat/StableApi.h>

#include <jsi/jsi.h>

Expand Down Expand Up @@ -32,8 +31,8 @@ class AnimatedSensorModule {
explicit AnimatedSensorModule(const PlatformDepMethodsHolder &platformDepMethodsHolder);

jsi::Value registerSensor(
jsi::Runtime &rt,
const std::shared_ptr<WorkletRuntime> &uiWorkletRuntime,
jsi::Runtime &rnRuntime,
const std::shared_ptr<WorkletRuntime> &uiRuntime,
const jsi::Value &sensorType,
const jsi::Value &interval,
const jsi::Value &iosReferenceFrame,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <reanimated/CSS/svg/values/SVGStops.h>
#include <reanimated/CSS/svg/values/SVGStrokeDashArray.h>

#include <worklets/Tools/JSISerializer.h>
#include <worklets/Compat/StableApi.h>

#include <string>
#include <utility>
Expand Down Expand Up @@ -41,7 +41,7 @@ CSSValueVariant<AllowedTypes...>::CSSValueVariant(jsi::Runtime &rt, const jsi::V
// Try constructing with each allowed type until one succeeds
if (!(tryOne.template operator()<AllowedTypes>() || ...)) {
throw std::runtime_error(
"[Reanimated] No compatible type found for construction from: " + worklets::stringifyJSIValue(rt, jsiValue));
"[Reanimated] No compatible type found for construction from: " + worklets::JSIValueToStdString(rt, jsiValue));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <reanimated/CSS/interpolation/PropertyInterpolator.h>

#include <worklets/Tools/JSISerializer.h>
#include <worklets/Compat/StableApi.h>

#include <memory>
#include <utility>
Expand Down Expand Up @@ -35,7 +35,7 @@ std::vector<std::pair<double, jsi::Value>> PropertyInterpolator::parseJSIKeyfram
throw std::invalid_argument(
"[Reanimated] Received invalid keyframes object for property: " + getPropertyPathString() +
".\n\nExpected an array of objects with 'offset' and 'value' properties, got: " +
worklets::stringifyJSIValue(rt, keyframes));
worklets::JSIValueToStdString(rt, keyframes));
}

const auto keyframeArray = keyframes.asObject(rt).asArray(rt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void UIEventHandler::process(
const std::shared_ptr<WorkletRuntime> &uiRuntime,
const double eventTimestamp,
const jsi::Value &eventValue) const {
uiRuntime->runSync(handlerFunction_, jsi::Value(eventTimestamp), eventValue);
runSyncOnRuntime(uiRuntime, handlerFunction_, jsi::Value(eventTimestamp), eventValue);
}

uint64_t UIEventHandler::getHandlerId() const {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#pragma once

#include <jsi/jsi.h>
#include <worklets/SharedItems/Serializable.h>
#include <worklets/WorkletRuntime/WorkletRuntime.h>
#include <worklets/Compat/StableApi.h>

#include <memory>
#include <string>
Expand All @@ -15,14 +14,14 @@ class UIEventHandler {
const uint64_t handlerId_;
const uint64_t emitterReactTag_;
const std::string eventName_;
const std::shared_ptr<worklets::SerializableWorklet> handlerFunction_;
const std::shared_ptr<worklets::Serializable> handlerFunction_;

public:
UIEventHandler(
const uint64_t handlerId,
const std::string &eventName,
const uint64_t emitterReactTag,
const std::shared_ptr<worklets::SerializableWorklet> &handlerFunction)
const std::shared_ptr<worklets::Serializable> &handlerFunction)
: handlerId_(handlerId),
emitterReactTag_(emitterReactTag),
eventName_(eventName),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ void UIEventHandlerRegistry::processEvent(
}
}

jsi::Runtime &rt = uiWorkletRuntime->getJSIRuntime();
eventPayload.asObject(rt).setProperty(rt, "eventName", jsi::String::createFromUtf8(rt, eventName));
jsi::Runtime &uiRuntime = getJSIRuntimeFromWorkletRuntime(uiWorkletRuntime);
eventPayload.asObject(uiRuntime).setProperty(
uiRuntime, "eventName", jsi::String::createFromUtf8(uiRuntime, eventName));
for (const auto &handler : handlersForEvent) {
handler->process(uiWorkletRuntime, eventTimestamp, eventPayload);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <jsi/jsi.h>
#include <worklets/WorkletRuntime/WorkletRuntime.h>
#include <worklets/Compat/StableApi.h>

#include <map>
#include <memory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <react/renderer/mounting/ShadowView.h>
#include <reanimated/LayoutAnimations/LayoutAnimationType.h>

#include <worklets/SharedItems/Serializable.h>
#include <worklets/Compat/StableApi.h>

#include <jsi/jsi.h>
#include <stdio.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <react/renderer/uimanager/UIManager.h>
#include <reanimated/LayoutAnimations/LayoutAnimationsManager.h>
#include <reanimated/Tools/PlatformDepMethodsHolder.h>
#include <worklets/Tools/UIScheduler.h>
#include <worklets/Compat/StableApi.h>

#include <memory>
#include <optional>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ void LayoutAnimationsProxy_Experimental::maybeCancelAnimation(const int tag) con
return;
}
layoutAnimations_.erase(tag);
uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), tag]() {
scheduleOnUI(uiScheduler_, [weakThis = weak_from_this(), tag]() {
auto strongThis = weakThis.lock();
if (!strongThis) {
return;
Expand Down Expand Up @@ -679,8 +679,8 @@ void LayoutAnimationsProxy_Experimental::startEnteringAnimation(const std::share
react_native_assert(parent && "Parent node is nullptr");
const auto parentTag = parent->current.tag;

uiScheduler_->scheduleOnUI(
[weakThis = weak_from_this(), finalView, currentView, newChildShadowView, parentTag, opacity]() {
scheduleOnUI(
uiScheduler_, [weakThis = weak_from_this(), finalView, currentView, newChildShadowView, parentTag, opacity]() {
auto strongThis = weakThis.lock();
if (!strongThis) {
return;
Expand Down Expand Up @@ -724,7 +724,7 @@ void LayoutAnimationsProxy_Experimental::startExitingAnimation(const std::shared
react_native_assert(parent && "Parent node is nullptr");
const auto parentTag = parent->current.tag;

uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), tag, parentTag, oldChildShadowView, surfaceId]() {
scheduleOnUI(uiScheduler_, [weakThis = weak_from_this(), tag, parentTag, oldChildShadowView, surfaceId]() {
auto strongThis = weakThis.lock();
if (!strongThis) {
return;
Expand Down Expand Up @@ -766,8 +766,8 @@ void LayoutAnimationsProxy_Experimental::startLayoutAnimation(const std::shared_
react_native_assert(parent && "Parent node is nullptr");
const auto parentTag = parent->current.tag;

uiScheduler_->scheduleOnUI(
[weakThis = weak_from_this(), surfaceId, oldChildShadowView, newChildShadowView, parentTag, tag]() {
scheduleOnUI(
uiScheduler_, [weakThis = weak_from_this(), surfaceId, oldChildShadowView, newChildShadowView, parentTag, tag]() {
auto strongThis = weakThis.lock();
if (!strongThis) {
return;
Expand Down Expand Up @@ -811,7 +811,7 @@ void LayoutAnimationsProxy_Experimental::startSharedTransition(
const ShadowView &before,
const ShadowView &after,
SurfaceId surfaceId) const {
uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), before, after, surfaceId, tag]() {
scheduleOnUI(uiScheduler_, [weakThis = weak_from_this(), before, after, surfaceId, tag]() {
auto strongThis = weakThis.lock();
if (!strongThis) {
return;
Expand Down Expand Up @@ -844,7 +844,7 @@ void LayoutAnimationsProxy_Experimental::startProgressTransition(
const ShadowView &before,
const ShadowView &after,
SurfaceId surfaceId) const {
uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), before, after, surfaceId]() {
scheduleOnUI(uiScheduler_, [weakThis = weak_from_this(), before, after, surfaceId]() {
auto strongThis = weakThis.lock();
if (!strongThis) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <reanimated/LayoutAnimations/LayoutAnimationsUtils.h>
#include <reanimated/Tools/PlatformDepMethodsHolder.h>

#include <worklets/Tools/UIScheduler.h>
#include <worklets/Compat/StableApi.h>

#include <react/renderer/componentregistry/ComponentDescriptorFactory.h>
#include <react/renderer/graphics/Transform.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ void LayoutAnimationsProxy_Legacy::startEnteringAnimation(const int tag, ShadowV
auto &viewProps = static_cast<const ViewProps &>(*mutation.newChildShadowView.props);
auto opacity = viewProps.opacity;

uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), finalView, current, mutation, opacity, tag]() {
scheduleOnUI(uiScheduler_, [weakThis = weak_from_this(), finalView, current, mutation, opacity, tag]() {
auto strongThis = weakThis.lock();
if (!strongThis) {
return;
Expand Down Expand Up @@ -675,7 +675,7 @@ void LayoutAnimationsProxy_Legacy::startExitingAnimation(const int tag, ShadowVi
#endif
auto surfaceId = mutation.oldChildShadowView.surfaceId;

uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), tag, mutation, surfaceId]() {
scheduleOnUI(uiScheduler_, [weakThis = weak_from_this(), tag, mutation, surfaceId]() {
auto strongThis = weakThis.lock();
if (!strongThis) {
return;
Expand Down Expand Up @@ -714,7 +714,7 @@ void LayoutAnimationsProxy_Legacy::startLayoutAnimation(const int tag, const Sha
#endif
auto surfaceId = mutation.oldChildShadowView.surfaceId;

uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), mutation, surfaceId, tag]() {
scheduleOnUI(uiScheduler_, [weakThis = weak_from_this(), mutation, surfaceId, tag]() {
auto strongThis = weakThis.lock();
if (!strongThis) {
return;
Expand Down Expand Up @@ -763,7 +763,7 @@ void LayoutAnimationsProxy_Legacy::maybeCancelAnimation(const int tag) const {
return;
}
layoutAnimations_.erase(tag);
uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), tag]() {
scheduleOnUI(uiScheduler_, [weakThis = weak_from_this(), tag]() {
auto strongThis = weakThis.lock();
if (!strongThis) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h>
#include <reanimated/LayoutAnimations/LayoutAnimationsUtils.h>
#include <reanimated/Tools/PlatformDepMethodsHolder.h>
#include <worklets/Tools/UIScheduler.h>
#include <worklets/Compat/StableApi.h>

#include <memory>
#include <string>
Expand Down
Loading
Loading