Skip to content

Commit

Permalink
fix(firestore, android): fix a race condition that could cause a cras…
Browse files Browse the repository at this point in the history
…h when adding event channels while closing the app (#11881)
  • Loading branch information
Lyokone committed Nov 14, 2023
1 parent 85e7129 commit 963c1b8
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,19 @@ private String registerEventChannel(String prefix, String identifier, StreamHand
}

private void removeEventListeners() {
for (String identifier : eventChannels.keySet()) {
eventChannels.get(identifier).setStreamHandler(null);
synchronized (eventChannels) {
for (String identifier : eventChannels.keySet()) {
eventChannels.get(identifier).setStreamHandler(null);
}
eventChannels.clear();
}
eventChannels.clear();

for (String identifier : streamHandlers.keySet()) {
streamHandlers.get(identifier).onCancel(null);
synchronized (streamHandlers) {
for (String identifier : streamHandlers.keySet()) {
streamHandlers.get(identifier).onCancel(null);
}
streamHandlers.clear();
}
streamHandlers.clear();

transactionHandlers.clear();
}
Expand Down

0 comments on commit 963c1b8

Please sign in to comment.