Merge commit 'b1ecac9d143cdce8bcd2d6071c0b8ff869daac7b' into 0.68-merge-latest

This commit is contained in:
Adam Gleitman 2022-06-03 13:56:07 -07:00
Родитель 92ba35285f b1ecac9d14
Коммит a94413e95b
8 изменённых файлов: 15 добавлений и 23 удалений

Просмотреть файл

@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
/*
* Finds and returns the closet RCTScrollViewComponentView component to the given view
*/
+ (RCTScrollViewComponentView *_Nullable)findScrollViewComponentViewForView:(UIView *)view;
+ (nullable RCTScrollViewComponentView *)findScrollViewComponentViewForView:(UIView *)view;
/*
* Returns an actual UIScrollView that this component uses under the hood.

Просмотреть файл

@ -396,8 +396,8 @@ public class ReactContext extends ContextWrapper {
return Assertions.assertNotNull(mJSMessageQueueThread).isOnThread();
}
public void runOnJSQueueThread(Runnable runnable) {
Assertions.assertNotNull(mJSMessageQueueThread).runOnQueue(runnable);
public boolean runOnJSQueueThread(Runnable runnable) {
return Assertions.assertNotNull(mJSMessageQueueThread).runOnQueue(runnable);
}
/**

Просмотреть файл

@ -19,7 +19,7 @@ public interface MessageQueueThread {
* if it is being submitted from the same queue Thread.
*/
@DoNotStrip
void runOnQueue(Runnable runnable);
boolean runOnQueue(Runnable runnable);
/**
* Runs the given Callable on this Thread. It will be submitted to the end of the event queue even

Просмотреть файл

@ -55,15 +55,17 @@ public class MessageQueueThreadImpl implements MessageQueueThread {
*/
@DoNotStrip
@Override
public void runOnQueue(Runnable runnable) {
public boolean runOnQueue(Runnable runnable) {
if (mIsFinished) {
FLog.w(
ReactConstants.TAG,
"Tried to enqueue runnable on already finished thread: '"
+ getName()
+ "... dropping Runnable.");
return false;
}
mHandler.post(runnable);
return true;
}
@DoNotStrip

Просмотреть файл

@ -223,13 +223,13 @@ jni::local_ref<Binding::jhybriddata> Binding::initHybrid(
// Thread-safe getter
jni::global_ref<jobject> Binding::getJavaUIManager() {
std::lock_guard<std::mutex> uiManagerLock(javaUIManagerMutex_);
std::shared_lock<better::shared_mutex> lock(installMutex_);
return javaUIManager_;
}
// Thread-safe getter
std::shared_ptr<Scheduler> Binding::getScheduler() {
std::lock_guard<std::mutex> lock(schedulerMutex_);
std::shared_lock<better::shared_mutex> lock(installMutex_);
return scheduler_;
}
@ -521,10 +521,7 @@ void Binding::installFabricUIManager(
// Use std::lock and std::adopt_lock to prevent deadlocks by locking mutexes
// at the same time
std::lock(schedulerMutex_, javaUIManagerMutex_);
std::lock_guard<std::mutex> schedulerLock(schedulerMutex_, std::adopt_lock);
std::lock_guard<std::mutex> uiManagerLock(
javaUIManagerMutex_, std::adopt_lock);
std::unique_lock<better::shared_mutex> lock(installMutex_);
javaUIManager_ = make_global(javaUIManager);
@ -625,13 +622,8 @@ void Binding::uninstallFabricUIManager() {
LOG(WARNING) << "Binding::uninstallFabricUIManager() was called (address: "
<< this << ").";
}
// Use std::lock and std::adopt_lock to prevent deadlocks by locking mutexes
// at the same time
std::lock(schedulerMutex_, javaUIManagerMutex_);
std::lock_guard<std::mutex> schedulerLock(schedulerMutex_, std::adopt_lock);
std::lock_guard<std::mutex> uiManagerLock(
javaUIManagerMutex_, std::adopt_lock);
std::unique_lock<better::shared_mutex> lock(installMutex_);
animationDriver_ = nullptr;
scheduler_ = nullptr;
javaUIManager_ = nullptr;

Просмотреть файл

@ -178,8 +178,9 @@ class Binding : public jni::HybridClass<Binding>,
void uninstallFabricUIManager();
// Private member variables
better::shared_mutex installMutex_;
jni::global_ref<jobject> javaUIManager_;
std::mutex javaUIManagerMutex_;
std::shared_ptr<Scheduler> scheduler_;
// LayoutAnimations
void onAnimationStarted() override;
@ -187,9 +188,6 @@ class Binding : public jni::HybridClass<Binding>,
std::shared_ptr<LayoutAnimationDriver> animationDriver_;
std::unique_ptr<JBackgroundExecutor> backgroundExecutor_;
std::shared_ptr<Scheduler> scheduler_;
std::mutex schedulerMutex_;
better::map<SurfaceId, SurfaceHandler> surfaceHandlerRegistry_{};
better::shared_mutex
surfaceHandlerRegistryMutex_; // Protects `surfaceHandlerRegistry_`.

Просмотреть файл

@ -69,7 +69,7 @@ void JMessageQueueThread::runOnQueue(std::function<void()> &&runnable) {
jni::ThreadScope guard;
static auto method =
JavaMessageQueueThread::javaClassStatic()
->getMethod<void(Runnable::javaobject)>("runOnQueue");
->getMethod<jboolean(Runnable::javaobject)>("runOnQueue");
method(
m_jobj,
JNativeRunnable::newObjectCxxArgs(wrapRunnable(std::move(runnable)))

Просмотреть файл

@ -244,8 +244,8 @@ void CxxNativeModule::lazyInit() {
module_ = provider_();
provider_ = nullptr;
if (module_) {
methods_ = module_->getMethods();
module_->setInstance(instance_);
methods_ = module_->getMethods();
}
}