I have a simple webview to display web pages via the network. It loads most pages fine but whenever I try to load http://www.nytimes.com
, it shows up as blank. The logcat at this point is:
09-11 11:26:18.428 10567-10630/com.project.test.webviewtest W/cr_media: Requires BLUETOOTH permission
09-11 11:26:18.454 10567-10567/com.project.test.webviewtest W/cr_AwContents: onDetachedFromWindow called when already detached. Ignoring
09-11 11:26:18.470 10567-10567/com.project.test.webviewtest I/cr_Ime: ImeThread is not enabled.
09-11 11:26:18.486 10567-10650/com.project.test.webviewtest D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
09-11 11:26:18.512 10567-10657/com.project.test.webviewtest E/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)
09-11 11:26:18.530 10567-10650/com.project.test.webviewtest I/OpenGLRenderer: Initialized EGL, version 1.4
09-11 11:26:18.538 10567-10657/com.project.test.webviewtest W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
09-11 11:26:18.557 10567-10657/com.project.test.webviewtest I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es
09-11 11:26:18.926 10567-10567/com.project.test.webviewtest W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 10567
09-11 11:26:18.946 10567-10567/com.project.test.webviewtest W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 10567
09-11 11:26:18.963 10567-10567/com.project.test.webviewtest W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 10567
09-11 11:26:19.313 10567-10567/com.project.test.webviewtest W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 10567
09-11 11:26:19.315 10567-10567/com.project.test.webviewtest W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 10567
09-11 11:26:19.316 10567-10567/com.project.test.webviewtest W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 10567
09-11 11:26:19.339 10567-10567/com.project.test.webviewtest W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 10567
09-11 11:26:19.438 10567-10628/com.project.test.webviewtest W/chromium: [WARNING:spdy_session.cc(2462)] Received HEADERS for invalid stream 3
My MainActivity
:
public class MainActivity extends AppCompatActivity {
private WebView mWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mWebView = (WebView) findViewById(R.id.activity_main_webview);
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.getSettings().setDomStorageEnabled(true);
mWebView.setWebViewClient(new TestWebViewClient());
mWebView.loadUrl("http://www.nytimes.com");
}
}
My TestWebViewClient
:
public class TestWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Log.i("WEB_VIEW_TEST", "error code:" + errorCode);
super.onReceivedError(view, errorCode, description, failingUrl);
}
}
I have added the INTERNET permission in the manifest. So far any other web page I have tried loads up fine. Just this one shows up as blank. I am not sure if the logcat shows the actual error as some things such as the EGL_BAD_DISPLAY
and the Cannot call determinedVisibility()
errors often show up in the successful loads as well. I don't usually see the last line [WARNING:spdy_session.cc(2462)] Received HEADERS for invalid stream 3
so maybe this is a cause of concern? I do not see any error being received in the onReceivedError
in the TestwebViewClient
.
Also sometimes (rarely), when I launch the app after a fresh install, the New York Times page title does show up for a second before the view going blank, which probably suggests this is a rendering issue and not a problem with the web view.
I am running this on a physical device running Android M.
Update: I tried printing the url in the shouldOverrideUrlLoading
and initially it goes to the correct redirected url: http://mobile.nytimes.com/?referer=
but then it switches to data:text/html
. I am not sure what to make of it and why it switches to this one. The redirection by itself should not be a problem as youtube.com
correctly loads after getting redirected to m.youtube.com
So i figured out the issue but still don't know the cause. The page opens if I comment out shouldOverrideUrlLoading
in TestWebViewClient.
I am not sure why this is a problem for just this page but it works for other pages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With