Skip to content
Open
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 @@ -395,18 +395,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 @@ -38,7 +38,7 @@ using SynchronouslyUpdateUIPropsFunction =
std::function<void(const int, const folly::dynamic &)>;
#endif // ANDROID
using PreserveMountedTagsFunction =
std::function<std::optional<std::unique_ptr<int[]>>(std::vector<int> &)>;
std::function<std::unique_ptr<int[]>(std::vector<int> &)>;
using GetAnimationTimestampFunction = std::function<double(void)>;

using ProgressLayoutAnimationFunction =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,21 +174,14 @@ void NativeProxy::maybeFlushUIUpdatesQueue() {
method(javaPart_.get());
}

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>)>(
"preserveMountedTags");
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 @@ -53,8 +53,7 @@ class NativeProxy : public jni::HybridClass<NativeProxy>,
// std::shared_ptr<facebook::react::Scheduler> reactScheduler_;
// std::shared_ptr<EventListener> eventListener_;
void installJSIBindings();
std::optional<std::unique_ptr<int[]>> preserveMountedTags(
std::vector<int> &tags);
std::unique_ptr<int[]> preserveMountedTags(std::vector<int> &tags);
void synchronouslyUpdateUIProps(
const std::vector<int> &intBuffer,
const std::vector<double> &doubleBuffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,19 +289,16 @@ private static String transformCommandToString(int transformCommand) {
};
}

/** 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) {
tags[i] = -1;
}
}

return true;
}

@DoNotStrip
Expand Down
Loading