@@ -1244,6 +1244,23 @@ public void handleMessage(Message msg) {
12441244 + " arg1=" + msg .arg1 + " arg2=" + msg .arg2
12451245 + " obj=" + msg .obj );
12461246 }
1247+ switch (msg .what ) {
1248+ case PAUSE_TIMERS :
1249+ mSavedPriority = Process .getThreadPriority (mTid );
1250+ Process .setThreadPriority (mTid ,
1251+ Process .THREAD_PRIORITY_BACKGROUND );
1252+ pauseTimers ();
1253+ if (mNativeClass != 0 ) {
1254+ nativeCloseIdleConnections (mNativeClass );
1255+ }
1256+ return ;
1257+
1258+ case RESUME_TIMERS :
1259+ Process .setThreadPriority (mTid , mSavedPriority );
1260+ resumeTimers ();
1261+ return ;
1262+ }
1263+
12471264 if (mWebView == null || mNativeClass == 0 ) {
12481265 if (DebugFlags .WEB_VIEW_CORE ) {
12491266 Log .w (LOGTAG , "Rejecting message " + msg .what
@@ -1252,8 +1269,6 @@ public void handleMessage(Message msg) {
12521269 return ;
12531270 }
12541271 if (mDestroying == true
1255- && msg .what != EventHub .RESUME_TIMERS
1256- && msg .what != EventHub .PAUSE_TIMERS
12571272 && msg .what != EventHub .DESTROY ) {
12581273 if (DebugFlags .WEB_VIEW_CORE ) {
12591274 Log .v (LOGTAG , "Rejecting message " + msg .what
@@ -1419,18 +1434,6 @@ public void handleMessage(Message msg) {
14191434 restoreState (msg .arg1 );
14201435 break ;
14211436
1422- case PAUSE_TIMERS :
1423- mSavedPriority = Process .getThreadPriority (mTid );
1424- Process .setThreadPriority (mTid ,
1425- Process .THREAD_PRIORITY_BACKGROUND );
1426- pauseTimers ();
1427- nativeCloseIdleConnections (mNativeClass );
1428- break ;
1429-
1430- case RESUME_TIMERS :
1431- Process .setThreadPriority (mTid , mSavedPriority );
1432- resumeTimers ();
1433- break ;
14341437
14351438 case ON_PAUSE :
14361439 nativePause (mNativeClass );
@@ -1961,12 +1964,10 @@ void removeMessages() {
19611964 */
19621965 void destroy () {
19631966 synchronized (mEventHub ) {
1964- // Do not call removeMessages as then we risk removing PAUSE_TIMERS
1965- // or RESUME_TIMERS messages, which we must still handle as they
1966- // are per process. DESTROY will instead trigger a white list in
1967- // mEventHub, skipping any remaining messages in the queue
1967+ // send DESTROY to front of queue
1968+ // PAUSE/RESUME timers will still be processed even if they get handled later
19681969 mEventHub .mDestroying = true ;
1969- mEventHub .sendMessage (
1970+ mEventHub .sendMessageAtFrontOfQueue (
19701971 Message .obtain (null , EventHub .DESTROY ));
19711972 mEventHub .blockMessages ();
19721973 }
0 commit comments