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 @@ -412,18 +412,18 @@ void LayoutAnimationsProxy::addOngoingAnimations(
SurfaceId surfaceId,
ShadowViewMutationList &mutations) const {
auto &updateMap = surfaceManager.getUpdateMap(surfaceId);
if (updateMap.empty()) {
return;
}

#ifdef ANDROID
std::vector<int> tagsToUpdate;
tagsToUpdate.reserve(updateMap.size());
for (auto &[tag, updateValues] : updateMap) {
tagsToUpdate.push_back(tag);
}

auto maybeCorrectedTags = preserveMountedTags_(tagsToUpdate);
if (!maybeCorrectedTags.has_value()) {
return;
}

auto correctedTags = maybeCorrectedTags->get();
auto correctedTags = preserveMountedTags_(tagsToUpdate);

// since the map is not updated, we can assume that the ordering of tags in
// correctedTags matches the iterator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ using RequestRenderFunction =
std::function<void(std::function<void(const double)>)>;
#ifdef ANDROID
using PreserveMountedTagsFunction =
std::function<std::optional<std::unique_ptr<int[]>>(std::vector<int> &)>;
std::function<std::unique_ptr<int[]>(std::vector<int> &)>;
#endif // ANDROID
using GetAnimationTimestampFunction = std::function<double(void)>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,18 @@ private native HybridData initHybrid(

public native void performOperations();

/**
* Modifies tags in place, setting not mounted view tags to -1 at their index.
*/
@DoNotStrip
public boolean preserveMountedTags(int[] tags) {
if (!UiThreadUtil.isOnUiThread()) {
return false;
}

public void preserveMountedTags(int[] tags) {
for (int i = 0; i < tags.length; i++) {
// Note: resolveView has assertOnUiThread, which only logs as softexception in debug
// It is actually completely thread safe and there is a RFC in RN to do something about it
if (mFabricUIManager.resolveView(tags[i]) == null) {
Log.w("[REANIMATED]", "View not found for tag: " + tags[i] + " in preserveMountedTags");
tags[i] = -1;
}
}

return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,21 +237,15 @@ void NativeProxy::synchronouslyUpdateUIProps(
method(javaPart_.get(), tag, uiProps);
}

std::optional<std::unique_ptr<int[]>> NativeProxy::preserveMountedTags(
std::unique_ptr<int[]> NativeProxy::preserveMountedTags(
std::vector<int> &tags) {
if (tags.empty()) {
return {};
}

static const auto method =
getJniMethod<jboolean(jni::alias_ref<jni::JArrayInt>)>(
getJniMethod<void(jni::alias_ref<jni::JArrayInt>)>(
"preserveMountedTags");
auto jArrayInt = jni::JArrayInt::newArray(tags.size());
jArrayInt->setRegion(0, tags.size(), tags.data());

if (!method(javaPart_.get(), jArrayInt)) {
return {};
}
method(javaPart_.get(), jArrayInt);

auto region = jArrayInt->getRegion(0, tags.size());
return region;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class NativeProxy : public jni::HybridClass<NativeProxy> {
void installJSIBindings();
#ifdef RCT_NEW_ARCH_ENABLED
void synchronouslyUpdateUIProps(Tag viewTag, const folly::dynamic &props);
std::optional<std::unique_ptr<int[]>> preserveMountedTags(
std::unique_ptr<int[]> preserveMountedTags(
std::vector<int> &tags);
#endif // RCT_NEW_ARCH_ENABLED
PlatformDepMethodsHolder getPlatformDependentMethods();
Expand Down
Loading