When using WebView.loadUrl(url);
on Android or some versions of Android the application ends alone (crash) in case the failure occurred in versions 6 and 7 of Android.
Notes:
- GPU Host is enabled on emulators
- Problem occurs on mobile as well
The only way the problem does not occur is Disable hardware acceleration like this :
<activity android:hardwareAccelerated="false" />
But this makes application performance worse, I would use acceleration and "prevent" the error from occurring.
I've added the permissions (this is because minSdk is 19):
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.guilherme.webviewexample">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
The build.gradle
looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
...
And the code like this:
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myWebView = (WebView) findViewById(R.id.myWebView);
WebViewClient clientInterface = new WebViewClient();
WebView myWebView = (WebView) findViewById(R.id.myWebView);
WebSettings wbset = myWebView.getSettings();
wbset.setJavaScriptEnabled(true);
myWebView.setWebViewClient(clientInterface);
String url = "http://pt.stackoverflow.com";
myWebView.loadUrl(url);
}
I believe the error is this:
Gles2DecoderImpl :: ResizeOffscreenFrameBuffer failed to allocate storage for offscreen target depth buffer.
Follow the LOG at crash:
11-10 10:52:13.779 22603-22603/com.example.guilherme.webviewexample I/chromium: [INFO:async_pixel_transfer_manager_android.cc(56)] Async pixel transfers not supported 11-10 10:52:13.809 22603-22603/com.example.guilherme.webviewexample E/chromium: [ERROR:gles2_cmd_decoder.cc(3389)] GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed to allocate storage for offscreen target depth buffer. 11-10 10:52:13.809 22603-22603/com.example.guilherme.webviewexample E/chromium: [ERROR:gles2_cmd_decoder.cc(2433)] Could not allocate offscreen buffer storage. 11-10 10:52:13.809 22603-22603/com.example.guilherme.webviewexample E/chromium: [ERROR:in_process_command_buffer.cc(465)] Could not initialize decoder. 11-10 10:52:13.809 22603-22603/com.example.guilherme.webviewexample A/libc: Fatal signal 11 (SIGSEGV) at 0x00000048 (code=1), thread 22603 (.webviewexample)