Skip to content

Commit

Permalink
Fix concurrent consumers issue with ReactMarker (#38710)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #38710

Fix a race condition when multiple consumers try to access ReactMarker and trigger calls to native module. Even though ReactMarker uses `ConcurrentLinkedQueue`, the loop itself could race and cause NPE.

Changelog:
[Android][Fixed] - Fix race condition with ReactMarker calls to its native module

Reviewed By: rshest

Differential Revision: D47933993

fbshipit-source-id: 502fa95b69aae07444bf48a5f30c094750abed25
  • Loading branch information
Xin Chen authored and facebook-github-bot committed Aug 1, 2023
1 parent 4b84a2b commit 13ad206
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ private static void notifyNativeMarker(ReactMarkerConstants name, @Nullable Long
nativeLogMarker(name.name(), now);

// Then send all cached native ReactMarkers
while (!sNativeReactMarkerQueue.isEmpty()) {
ReactMarkerRecord record = sNativeReactMarkerQueue.poll();
ReactMarkerRecord record;
while ((record = sNativeReactMarkerQueue.poll()) != null) {
nativeLogMarker(record.getMarkerName(), record.getMarkerTime());
}
} else {
Expand Down

0 comments on commit 13ad206

Please sign in to comment.