New issue
Advanced search Search tips

Issue 765563 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner: ----
Closed: Oct 2017
Cc:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug



Sign in to add a comment

CTS WebViewHostSideStartupTest#testStrictMode fails.

Project Member Reported by jie.a.c...@intel.com, Sep 15 2017

Issue description

Webview Version: any
OS: (Android O)

What steps will reproduce the problem?

(1)prepare a x86_64 device to run CTS 8.0.0_R1
(2)run cts -m CtsHostsideWebViewTests -t com.android.cts.webkit.WebViewHostSideStartupTest#testStrictMode

The violation log was :

08-24 12:07:58.292 10747 10747 D StrictMode: StrictMode policy violation; ~duration=385 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=327743 violation=2
08-24 12:07:58.292 10747 10747 D StrictMode:    at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1438)
08-24 12:07:58.292 10747 10747 D StrictMode:    at java.io.FileInputStream.<init>(FileInputStream.java:149)
08-24 12:07:58.292 10747 10747 D StrictMode:    at java.io.FileInputStream.<init>(FileInputStream.java:103)
08-24 12:07:58.292 10747 10747 D StrictMode:    at android.telephony.TelephonyManager.getProcCmdLine(TelephonyManager.java:1399)
08-24 12:07:58.292 10747 10747 D StrictMode:    at android.telephony.TelephonyManager.<clinit>(TelephonyManager.java:1420)
08-24 12:07:58.292 10747 10747 D StrictMode:    at android.app.SystemServiceRegistry$37.createService(SystemServiceRegistry.java:471)
08-24 12:07:58.292 10747 10747 D StrictMode:    at android.app.SystemServiceRegistry$37.createService(SystemServiceRegistry.java:468)
08-24 12:07:58.292 10747 10747 D StrictMode:    at android.app.SystemServiceRegistry$CachedServiceFetcher.getService(SystemServiceRegistry.java:928)
08-24 12:07:58.292 10747 10747 D StrictMode:    at android.app.SystemServiceRegistry.getSystemService(SystemServiceRegistry.java:880)
08-24 12:07:58.292 10747 10747 D StrictMode:    at android.app.ContextImpl.getSystemService(ContextImpl.java:1651)
08-24 12:07:58.292 10747 10747 D StrictMode:    at android.content.ContextWrapper.getSystemService(ContextWrapper.java:708)
08-24 12:07:58.292 10747 10747 D StrictMode:    at org.chromium.android_webview.ResourcesContextWrapperFactory$WebViewContextWrapper.getSystemService(ResourcesContextWrapperFactory.java:80)
08-24 12:07:58.292 10747 10747 D StrictMode:    at org.chromium.net.AndroidNetworkLibrary.getNetworkCountryIso(AndroidNetworkLibrary.java:161)
08-24 12:07:58.292 10747 10747 D StrictMode:    at org.chromium.android_webview.AwContents.nativeGetWebContents(Native Method)
08-24 12:07:58.292 10747 10747 D StrictMode:    at org.chromium.android_webview.AwContents.setNewAwContents(AwContents.java:1070)
08-24 12:07:58.292 10747 10747 D StrictMode:    at org.chromium.android_webview.AwContents.<init>(AwContents.java:817)
08-24 12:07:58.292 10747 10747 D StrictMode:    at com.android.webview.chromium.WebViewChromium.initForReal(WebViewChromium.java:236)
08-24 12:07:58.292 10747 10747 D StrictMode:    at com.android.webview.chromium.WebViewChromium.access$000(WebViewChromium.java:84)
08-24 12:07:58.292 10747 10747 D StrictMode:    at com.android.webview.chromium.WebViewChromium$1.run(WebViewChromium.java:202)
08-24 12:07:58.292 10747 10747 D StrictMode:    at com.android.webview.chromium.WebViewChromiumFactoryProvider$WebViewChromiumRunQueue.drainQueue(WebViewChromiumFactoryProvider.java:118)
08-24 12:07:58.292 10747 10747 D StrictMode:    at com.android.webview.chromium.WebViewChromiumFactoryProvider$WebViewChromiumRunQueue$1.run(WebViewChromiumFactoryProvider.java:105)
08-24 12:07:58.292 10747 10747 D StrictMode:    at org.chromium.base.ThreadUtils.runOnUiThread(ThreadUtils.java:155)
08-24 12:07:58.292 10747 10747 D StrictMode:    at com.android.webview.chromium.WebViewChromiumFactoryProvider$WebViewChromiumRunQueue.addTask(WebViewChromiumFactoryProvider.java:102)
08-24 12:07:58.292 10747 10747 D StrictMode:    at com.android.webview.chromium.WebViewChromiumFactoryProvider.addTask(WebViewChromiumFactoryProvider.java:157)
08-24 12:07:58.292 10747 10747 D StrictMode:    at com.android.webview.chromium.WebViewChromium.init(WebViewChromium.java:199)


The cause is: 
https://android.googlesource.com/a/platform/frameworks/base/+/master/telephony/java/android/telephony/TelephonyManager.java#1407

Under strict mode, file reads/writes are not allowed in UI thread in order not to make UI less responsive. So TelephonyManager reading /proc/cmdline definitely is illegal.

The function is called to initialize a static member of TelephonyManager:
https://android.googlesource.com/a/platform/frameworks/base/+/master/telephony/java/android/telephony/TelephonyManager.java#1428

As I know, the java VM does such initialization for statics when the class is firstly referenced. The TelephonyManager will be used as long as chromium calls getNetworkCountryIso(). So the violation seems inevitable.

I haven't got an feasible ARM device to verify the issue. But it's quite weird no one has reported it at lease on Nexus or Pixels.



 
Description: Show this description
Cc: boliu@chromium.org torne@chromium.org

Comment 3 by torne@chromium.org, Sep 15 2017

/proc reads aren't interesting strict mode violations (this kind of thing is never actually a blocking IO); when there's no alternative we just suppress these. It is surprising that this hasn't been reported already, though - possibly other devices are already calling this somewhere in other code earlier in the process beforehand, so it's already initialised, and this isn't happening on your device for some reason.

Also: is this even happening in the client process? TelephonyManager looks like the service implementation on the other side of the IPC call; if so then this is a framework bug (it should be protecting its callers from this violation).
Status: WontFix (was: Untriaged)
The root cause is zygote preloading classes. Normally the TelephonyManager class is in that list. But it's not the case in my IVI device for purpose of startup time optimization.

Torne, thank you anyway for the quick and informative reply!

Sign in to add a comment