Skip to content

Commit

Permalink
Fix bug in timer clean up
Browse files Browse the repository at this point in the history
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 #9361

Differential Revision: D3797573

fbshipit-source-id: c30ed600af741601f2babdfc61da9aac549cbadb
  • Loading branch information
Adam Comella authored and Facebook Github Bot 4 committed Aug 31, 2016
1 parent 69c8898 commit 06e52f8
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@ public void doFrame(long frameTimeNanos) {
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);
}
}
}
}
}
Expand Down Expand Up @@ -385,7 +391,10 @@ public void deleteTimer(ExecutorToken executorToken, int timerId) {
return;
}
// We may have already called/removed it
mTimerIdsToTimers.remove(executorToken);
timersForContext.remove(timerId);
if (timersForContext.size() == 0) {
mTimerIdsToTimers.remove(executorToken);
}
mTimers.remove(timer);
}
}
Expand Down

0 comments on commit 06e52f8

Please sign in to comment.