Fix bug in timer clean up
Summary: One of the impacts of this bug is that Java is firing timer completion events into JavaScript for timers that should have been deleted. JavaScript filters these out so it doesn't impact the app developer. However, Java is completing more timers than necessary. When cleaning up a timer, we were accidentally deleting the whole set of timers for that context. Instead, we should just delete that timer from its context. Adam Comella Microsoft Corp. Closes https://github.com/facebook/react-native/pull/9361 Differential Revision: D3797573 fbshipit-source-id: c30ed600af741601f2babdfc61da9aac549cbadb
This commit is contained in:
parent
69c889815e
commit
06e52f8e8c
|
@ -104,7 +104,13 @@ public final class Timing extends ReactContextBaseJavaModule implements Lifecycl
|
|||
timer.mTargetTime = frameTimeMillis + timer.mInterval;
|
||||
mTimers.add(timer);
|
||||
} else {
|
||||
mTimerIdsToTimers.remove(timer.mExecutorToken);
|
||||
SparseArray<Timer> timers = mTimerIdsToTimers.get(timer.mExecutorToken);
|
||||
if (timers != null) {
|
||||
timers.remove(timer.mCallbackID);
|
||||
if (timers.size() == 0) {
|
||||
mTimerIdsToTimers.remove(timer.mExecutorToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -385,7 +391,10 @@ public final class Timing extends ReactContextBaseJavaModule implements Lifecycl
|
|||
return;
|
||||
}
|
||||
// We may have already called/removed it
|
||||
mTimerIdsToTimers.remove(executorToken);
|
||||
timersForContext.remove(timerId);
|
||||
if (timersForContext.size() == 0) {
|
||||
mTimerIdsToTimers.remove(executorToken);
|
||||
}
|
||||
mTimers.remove(timer);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue