Trying to use the AWShellActivity and android.webkit.WebView at the same time

184 views
Skip to first unread message

Iker Jamardo

unread,
Mar 11, 2017, 10:07:33 PM3/11/17
to Chromium-dev
Hello,

I know it may sound a bit crazy but I am trying to use the android_webview APK provided inside Chromium along with trying to instantiate the system WebView. Inside the AwShellActivity I am trying to instantiate a android.webkit.WebView and I am getting the following exception:

03-11 18:47:59.761 13172 13172 E AndroidRuntime: java.nio.channels.OverlappingFileLockException
03-11 18:47:59.761 13172 13172 E AndroidRuntime: at sun.nio.ch.SharedFileLockTable.checkList(FileLockTable.java:255)
03-11 18:47:59.761 13172 13172 E AndroidRuntime: at sun.nio.ch.SharedFileLockTable.add(FileLockTable.java:152)
03-11 18:47:59.761 13172 13172 E AndroidRuntime: at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:1061)
03-11 18:47:59.761 13172 13172 E AndroidRuntime: at java.nio.channels.FileChannel.tryLock(FileChannel.java:977)
03-11 18:47:59.761 13172 13172 E AndroidRuntime: at com.android.webview.chromium.WebViewChromiumFactoryProvider.startChromiumLocked(WebViewChromiumFactoryProvider.java:15122)
03-11 18:47:59.761 13172 13172 E AndroidRuntime: at com.android.webview.chromium.WebViewChromiumFactoryProvider.ensureChromiumStartedLocked(WebViewChromiumFactoryProvider.java:347)
03-11 18:47:59.761 13172 13172 E AndroidRuntime: at com.android.webview.chromium.WebViewChromiumFactoryProvider.startYourEngines(WebViewChromiumFactoryProvider.java:440)
03-11 18:47:59.761 13172 13172 E AndroidRuntime: at com.android.webview.chromium.WebViewChromium.init(WebViewChromium.java:162)
03-11 18:47:59.761 13172 13172 E AndroidRuntime: at android.webkit.WebView.<init>(WebView.java:636)
03-11 18:47:59.761 13172 13172 E AndroidRuntime: at android.webkit.WebView.<init>(WebView.java:572)
03-11 18:47:59.761 13172 13172 E AndroidRuntime: at android.webkit.WebView.<init>(WebView.java:555)
03-11 18:47:59.761 13172 13172 E AndroidRuntime: at android.webkit.WebView.<init>(WebView.java:542)
03-11 18:47:59.761 13172 13172 E AndroidRuntime: at android.webkit.WebView.<init>(WebView.java:532)
03-11 18:47:59.761 13172 13172 E AndroidRuntime: at org.chromium.android_webview.shell.AwShellActivity$WebView.<init>(AwShellActivity.java:146)
03-11 18:47:59.761 13172 13172 E AndroidRuntime: at org.chromium.android_webview.shell.AwShellActivity$7.run(AwShellActivity.java:1079)
03-11 18:47:59.761 13172 13172 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:751)
03-11 18:47:59.761 13172 13172 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95)
03-11 18:47:59.761 13172 13172 E AndroidRuntime: at android.os.Looper.loop(Looper.java:154)
03-11 18:47:59.761 13172 13172 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6119)
03-11 18:47:59.761 13172 13172 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
03-11 18:47:59.761 13172 13172 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
03-11 18:47:59.761 13172 13172 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
03-11 18:47:59.763   991 31400 W ActivityManager:   Force finishing activity org.chromium.android_webview.shell/.AwShellActivity

Kind of makes sense that both the webview from the AwShellActivity and the android.webkit.WebView are both trying to lock the same resource, but is there a possible solution to this?

I think the solution could be to use tabs in full chromium instead of the webview example, but it would be great if I could resolve this in the android_webview APK example as I already have much code tight to it.

Is there a way to instantiate 2 webview instances?

Thank you very much as usual.

Torne (Richard Coles)

unread,
Mar 13, 2017, 8:06:23 AM3/13/17
to ijam...@gmail.com, Chromium-dev
If you're trying to embed the WebView code in your app, you need to make it use a different location for its data and cache directories so that it doesn't try to use the same directories as the actual WebView to store its data - the file formats we use are not safe for concurrent accesses.

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/0b7bf64a-98a5-4a0c-afc0-2ba093239e1e%40chromium.org.

Iker Jamardo

unread,
Mar 13, 2017, 9:49:27 AM3/13/17
to Chromium-dev, Torne (Richard Coles)
Thank you for your reply. Could you point me on how to change the base path? Is there a method to specify it?

Regards,
Iker

Torne (Richard Coles)

unread,
Mar 13, 2017, 11:51:30 AM3/13/17
to Iker Jamardo, Chromium-dev
There's not a single base path; there's multiple different things you'll have to update. AwBrowserProcess sets the data directory suffix, but that won't move the cache dir, which doesn't use that suffix to set its location (this was probably a poor choice on our part but it's awkward to change the directory layout now) - you'll have to dig around in PathUtils to try to change the other disk locations used.

Iker Jamardo

unread,
Mar 13, 2017, 2:13:15 PM3/13/17
to Torne (Richard Coles), Chromium-dev
Thank you. I tried changing the suffix and it seems to be working well for my purpose. I will investigate a bit further anyway.

Regards,
Iker

Torne (Richard Coles)

unread,
Mar 13, 2017, 2:17:09 PM3/13/17
to Iker Jamardo, Chromium-dev
If you change the suffix that will move the data directory but not the cache. The lock that protects you from concurrent access here is in the data directory, so moving the data directory will make the crash you were seeing go away, but does *not* mean that everything is now safe and working, because you'll still be sharing other directories. You need to change all the directories, not just one.
Reply all
Reply to author
Forward
0 new messages