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: a56e5e4f3564922d534235991da5b6842248bf24
  • Loading branch information
Xin Chen authored and facebook-github-bot committed Aug 1, 2023
1 parent 7437990 commit 6ab062d
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 6ab062d

Please sign in to comment.