New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 649224 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
OOO until Feb 4th
Closed: Sep 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 1
Type: Bug

Blocking:
issue 637448



Sign in to add a comment

Flakiness in chrome_public_apk step on trybots from ExceptionInInitializerError in org.chromium.base.ContextUtils.getAppSharedPreferences

Project Member Reported by kbr@chromium.org, Sep 22 2016

Issue description

There seems to be a significant amount of flakiness on the linux_android_rel_ng tryserver:
https://build.chromium.org/p/tryserver.chromium.android/builders/linux_android_rel_ng?numbuilds=200

from exceptions thrown in org.chromium.base.ContextUtils.getAppSharedPreferences . A couple of examples:

https://build.chromium.org/p/tryserver.chromium.android/builders/linux_android_rel_ng/builds/145928
https://build.chromium.org/p/tryserver.chromium.android/builders/linux_android_rel_ng/builds/145905

Stack traces:

org.chromium.chrome.browser.instantapps.InstantAppsHandlerTest#testInstantAppsDisabled_incognito (run #1):
java.lang.ExceptionInInitializerError
	at org.chromium.base.ContextUtils.getAppSharedPreferences(ContextUtils.java:96)
	at org.chromium.chrome.browser.instantapps.InstantAppsHandlerTest.setUp(InstantAppsHandlerTest.java:40)
	at org.chromium.base.test.BaseTestResult.run(BaseTestResult.java:129)
	at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
	at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
	at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
	at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)
Caused by: java.lang.NullPointerException
	at android.preference.PreferenceManager.getDefaultSharedPreferencesName(PreferenceManager.java:374)
	at android.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:369)
	at org.chromium.base.ContextUtils.access$000(ContextUtils.java:2085)
	at org.chromium.base.ContextUtils$Holder.<clinit>(ContextUtils.java:26)
	... 12 more


org.chromium.chrome.browser.identity.UuidBasedUniqueIdentificationGeneratorTest#testGenerationAndRestorationOfUuid (run #1):
java.lang.ExceptionInInitializerError
	at org.chromium.base.ContextUtils.getAppSharedPreferences(ContextUtils.java:96)
	at org.chromium.chrome.browser.identity.UuidBasedUniqueIdentificationGenerator.getUniqueId(UuidBasedUniqueIdentificationGenerator.java:32)
	at org.chromium.chrome.browser.identity.UuidBasedUniqueIdentificationGeneratorTest.testGenerationAndRestorationOfUuid(UuidBasedUniqueIdentificationGeneratorTest.java:34)
	at java.lang.reflect.Method.invokeNative(Native Method)
	at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
	at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
	at org.chromium.base.test.BaseTestResult.run(BaseTestResult.java:129)
	at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
	at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
	at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
	at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)
Caused by: java.lang.NullPointerException
	at android.preference.PreferenceManager.getDefaultSharedPreferencesName(PreferenceManager.java:374)
	at android.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:369)
	at org.chromium.base.ContextUtils.access$000(ContextUtils.java:2085)
	at org.chromium.base.ContextUtils$Holder.<clinit>(ContextUtils.java:26)
	... 17 more

I'm not sure what component this should be in but am CC'ing a couple of other folks that are CC'd on other bugs mentioning ContextUtils.

This affects one of the main Chromium tryservers and is therefore high priority.

I suspect this impacts  Issue 637448  and am blocking that on this one.

 

Comment 1 by torne@chromium.org, Sep 22 2016

Owner: wnwen@chromium.org
Status: Assigned (was: Untriaged)
Ian, looks like these tests haven't set the context early enough?

Comment 2 by wnwen@chromium.org, Sep 23 2016

Looking into this. If these tests aren't setting the context early enough then they should fail all the time. Seems like something is causing it to be set sometimes and not set other times, which is very strange.

Comment 4 by wnwen@chromium.org, Sep 27 2016

There is definitely a race condition between instrumentation tests creating the application and the test code being run. Will see if moving ContextUtils initialization earlier solves the problem.
Project Member

Comment 5 by bugdroid1@chromium.org, Sep 27 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/640e90121d42acc469a533ae190e311841189827

commit 640e90121d42acc469a533ae190e311841189827
Author: wnwen <wnwen@chromium.org>
Date: Tue Sep 27 17:46:01 2016

Fix ContextUtils test flakiness.

There was a race condition between Android tests calling
Application#onCreate and TestRunner#runTests which caused flakiness
in some of the UrlManagerTest* and other instrumentation tests.

Initialize the application object earlier so that it is always ready
when tests are run.

BUG= 649224 , 637448 

Review-Url: https://codereview.chromium.org/2363323003
Cr-Commit-Position: refs/heads/master@{#421256}

[modify] https://crrev.com/640e90121d42acc469a533ae190e311841189827/chrome/android/java/src/org/chromium/chrome/browser/ChromeApplication.java

Comment 6 by wnwen@chromium.org, Sep 27 2016

Status: Fixed (was: Assigned)

Comment 7 by kbr@chromium.org, Sep 27 2016

Fantastic. Thank you for getting to the bottom of this.

Sign in to add a comment