diff options
author | pliard@chromium.org <pliard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-21 11:37:16 +0000 |
---|---|---|
committer | pliard@chromium.org <pliard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-21 11:37:16 +0000 |
commit | a54d293a94d9876cc9845eb035ee5a462aa1c4ee (patch) | |
tree | bb2bb2c9c07a4ba3804f7a43fe91090f5c105867 /base | |
parent | 098889248e162d6c901cec413cd4a47ef802492d (diff) | |
download | chromium_src-a54d293a94d9876cc9845eb035ee5a462aa1c4ee.zip chromium_src-a54d293a94d9876cc9845eb035ee5a462aa1c4ee.tar.gz chromium_src-a54d293a94d9876cc9845eb035ee5a462aa1c4ee.tar.bz2 |
Fix crash in Android NCN due to the use of ActivityStatus.CREATED event.
NetworkChangeNotifierAutoDetect was subscribing to the ActivityStatus.CREATED
event to perform its initialization which seems reasonable. Unfortunately this
event can't be used reliably since its notification is deferred (i.e. observers
are notified a long time after Main.onCreate() is called). This means that the
CREATED event can follow any event including STOPPED which is problematic.
Here is what was happening in this specific case:
Main activity: CREATED -> RESUMED -> PAUSED -> STOPPED -------------> DESTROYED
NetworkChangeNotifierAutoDetect: STOPPED -> CREATED
This is problematic since NetworkChangeNotifierAutoDetect must unregister its
intent receiver before the main activity is destroyed which was impossible in
this case since the last event NCNAutoDetect was seeing before the DESTROYED
event (which it doesn't handle) was CREATED.
One could argue that the correct fix would be to have NCNAutoDetect handle the
DESTROYED event. However clients of ActivityStatus should not have to deal
manually with the DESTROYED event in theory since this event is always
preceded by STOPPED (according to the standard Android activity life cycle
graph). This is only true of course if ActivityStatus follows this life cycle
graph (which it should do) but this is not the case unfortunately for now since
the CREATED event is deferred.
TBR=digit
BUG=176292,176837
Review URL: https://codereview.chromium.org/12321044
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@183790 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/android/java/src/org/chromium/base/ActivityStatus.java | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/base/android/java/src/org/chromium/base/ActivityStatus.java b/base/android/java/src/org/chromium/base/ActivityStatus.java index e1b43c4..c89a0f8 100644 --- a/base/android/java/src/org/chromium/base/ActivityStatus.java +++ b/base/android/java/src/org/chromium/base/ActivityStatus.java @@ -54,12 +54,11 @@ public class ActivityStatus { */ public static void onStateChange(Activity activity, int newState) { if (sActivity != activity) { - // ActivityStatus is notified very late during the main activity creation to avoid - // making startup performance worse than it is by notifying observers that could do some - // expensive work. This can lead to the RESUMED event being fired before the CREATED - // event in case the activity is resumed. - // TODO(pliard): http://crbug.com/176837. - assert newState == CREATED || newState == RESUMED; + // ActivityStatus is notified with the CREATED event very late during the main activity + // creation to avoid making startup performance worse than it is by notifying observers + // that could do some expensive work. This can lead to non-CREATED events being fired + // before the CREATED event which is problematic. + // TODO(pliard): fix http://crbug.com/176837. sActivity = activity; } sActivityState = newState; |