Blank page in WebView
Reported by
hir...@netstar-inc.com,
Feb 7 2018
|
||||
Issue descriptionTHIS TEMPLATE IS FOR FILING BUGS ON THE ANDROID SYSTEM WEBVIEW. GENERAL WEB BUGS SHOULD BE FILED USING A DIFFERENT TEMPLATE! Device name:Nexus 6P Android version:8.1.0 WebView version (from system settings -> Apps -> Android System WebView):disable(Chrome version:64.0.3282.137) Application:custom webview Application version: URLs (if applicable):https://m.yahoo.co.jp/ Steps to reproduce: (1)Create empty android project. (2)Add the following code to onCreate() of MainActivity. super.onCreate(savedInstanceState); setContentView(R.layout.main); WebView wv = (WebView) findViewById(R.id.webView); wv.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { Map<String, String> addHeaders = new HashMap<String, String>(); addHeaders.put("X-SAMPLEHEADER", url); view.loadUrl(url, addHeaders); return false; } }); wv.loadUrl("https://m.yahoo.co.jp"); (3)Perform an arbitrary search on the displayed page. (4)Tap any tab. Expected result: Content is displayed correctly. Actual result: A blank page is displayed. It will be reproduced even if it is executed with the next shouldOverrideUrlLoading(). ・boolean shouldOverrideUrlLoading (WebView view, WebResourceRequest request) It can also be reproduced by executing loadUrl(String url) without passing a header. Even if Android System WebView is enabled, the result will not change.
,
Feb 8 2018
,
Feb 8 2018
Thank you for your reply. Please refer to the attached file.
,
Feb 8 2018
Thank you for providing more feedback. Adding requester "sandeepkumars@chromium.org" to the cc list and removing "Needs-Feedback" label. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Feb 8 2018
your apk doesn't work. looks like it's a multi-dex apk, and you only provided the main one. but the main problem is your shouldOverrideUrlLoading implementation. You should 1) return true from shouldOverrideUrlLoading (only if you actually want to stop that load and replace it with a different one, which are doing in that code snippet at least) 2) post the loadUrl call instead of calling it directly from shouldOverrideUrlLoading
,
Feb 9 2018
I'm sorry.
return false of shouldOverrideUrlLoading is a typo.
I changed shouldOverrideUrlLoading as below, but the result does not change.
I attach an apk.
- -
@Override
public boolean shouldOverrideUrlLoading(final WebView view, final String url) {
view.post(new Runnable() {
@Override
public void run() {
Map<String, String> addHeaders = new HashMap<String, String>();
addHeaders.put("X-SAMPLEHEADER", url);
view.loadUrl(url, addHeaders);
}
});
return true;
}
- -
Although postDelayed delayed for 1 second will work correctly, I think this 1 second delay should be avoided for every load.
,
Mar 12 2018
I can confirm that I am seeing the same issue with 65.0.3325.109. @boliu regarding #c5. I am using loadUrl correctly within shouldOverrideUrlLoading(). 1. Calling loadUrl() within shouldOverrideUrlLoading() is the only currently-supported way to pass extra HTTP headers. 2. Simply post()’ing it doesn’t make a difference, as #c6 says. The delay has to be long enough, which makes every navigation slow, and is unacceptable. Please re-open this bug for a complete investigation.
,
Mar 12 2018
I said post, not post with delay. The problem is that shouldOverrideUrlLoading is called directly from navigation code (since the navigation depends on the return value), so calling loadUrl again is re-entering into navigation code, which is really undefined what happens in that case. |
||||
►
Sign in to add a comment |
||||
Comment 1 by sandeepkumars@chromium.org
, Feb 8 2018Labels: Needs-triage-Mobile WV-Triaged