Skip to content

Commit

Permalink
Fix concurrent consumers issue with ReactMarker
Browse files Browse the repository at this point in the history
Summary:
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

Differential Revision: D47933993

fbshipit-source-id: 8578132e353fdb3829a90355f8fc3c69528a8dd3
  • Loading branch information
Xin Chen authored and facebook-github-bot committed Jul 31, 2023
1 parent 3eccc53 commit 95db149
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 95db149

Please sign in to comment.