Fix data race in usage of ShadowTreeRevisionConsistencyManager (#51293)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51293

# Changelog:
[Internal] -

Indirect consequence of https://github.com/facebook/react-native/pull/50484, TSAN started to detect a data race in some configurations.

It's possible to have the data race between the `ShadowTreeRevisionConsistencyManager` being set in `RuntimeScheduler` and it being already used in the executor thread (as these things are generally done from different threads).

Differential Revision: D74651070

fbshipit-source-id: bda49371d541815119f119e6986de39c21f9b374
This commit is contained in:
Ruslan Shestopalyuk authored and Facebook GitHub Bot committed 2025-05-13 09:39:04 -07:00
1 parent 1d5bbf1ccf
commit 80eed4a4a7
2 files changed
+4 -4

No files matched your search

@@ -182,8 +182,8 @@ class RuntimeScheduler_Legacy final : public RuntimeSchedulerBase {
*/
std::atomic_bool isPerformingWork_{false};
ShadowTreeRevisionConsistencyManager* shadowTreeRevisionConsistencyManager_{
nullptr};
std::atomic<ShadowTreeRevisionConsistencyManager*>
shadowTreeRevisionConsistencyManager_{nullptr};
RuntimeSchedulerTaskErrorHandler onTaskError_;
};
@@ -225,8 +225,8 @@ class RuntimeScheduler_Modern final : public RuntimeSchedulerBase {
std::queue<RuntimeSchedulerRenderingUpdate> pendingRenderingUpdates_;
std::unordered_set<SurfaceId> surfaceIdsWithPendingRenderingUpdates_;
ShadowTreeRevisionConsistencyManager* shadowTreeRevisionConsistencyManager_{
nullptr};
std::atomic<ShadowTreeRevisionConsistencyManager*>
shadowTreeRevisionConsistencyManager_{nullptr};
PerformanceEntryReporter* performanceEntryReporter_{nullptr};
RuntimeSchedulerEventTimingDelegate* eventTimingDelegate_{nullptr};