Prevent ANR if window is stopped
When an activity is stopped, there could still be some pending events in the inputconsumer due to batching. Those events are supposed to be handled when choreographer's 'CALLBACK_INPUT' occurs, but this will never happen if the window is stopped. There are two possible ways these events can occur: 1. The last input event happens before onStop, but at that point, choreographer will already stop sending callbacks. The solution to this is to add a call to "consumeImmediately" inside setWindowStopped. 2. Input events come in after window has already been stopped. At that point, the callback we posted in 1. would already have executed (and found that there's no events). The solution to this is to immediately consume all input if mStopped=true. We do this by switching to "unbuffered" mode for simplicity. This is reproducible via monkey testing, but it's plausible that such race condition can occur in real world usage. Test: adb shell monkey --throttle 40 50000 Bug: 159239700 Change-Id: I74d8f55503ef7df2fd01931afb362d68e5026e86
Loading
Please register or sign in to comment