0

大多数网站页面在基于 Android 4.4(和更新版本)Chromium 的 webview 上运行良好。但最近我发现一个网站页面在 4.4(或更高版本)和更早的 Android 系统之间表现不同。

早期 Android 系统上的 webview 可以按预期工作,但在 KitKat 上则不行。我相信页面内部一定有一些技巧。但几周后我仍然坚持这个问题.. :(

你能帮忙吗?非常感谢。

以下是代码:

WebView WV_test = (WebView) findViewById(R.id.WV_query);
WV_test.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
WV_test.getSettings().setDomStorageEnabled(true);
WV_test.getSettings().setJavaScriptEnabled(true);
WV_test.setWebViewClient(new WebViewClient() {
	@Override
	public void onPageStarted(WebView view, String url, Bitmap favicon) {
		Log.v("attlog", "onPageStarted: url="+url);
		super.onPageStarted(view, url, favicon);
	}

	@Override
	public void onPageFinished(WebView view, String url) {
		Log.v("attlog", "onPageFinished: url="+url);
		super.onPageFinished(view, url);
	}
	@Override
	public void onLoadResource(WebView view, String url) {
		Log.v("attlog", "onLoadResource() url="+url);
		super.onLoadResource(view, url);
	}
});

String url="http://railway.hinet.net/ccancel_rt.jsp";
Log.v("attlog", "url="+url );
WV_test.loadUrl( url );

早期 webkit(即 4.1)的结果按预期工作:

url=http://railway.hinet.net/ccancel_rt.jsp
onPageStarted: url=http://railway.hinet.net/ccancel_rt.jsp
onLoadResource() url=http://railway.hinet.net/ccancel_rt.jsp
onLoadResource() url=http://railway.hinet.net/4QbVtADbnLVIc/c.FxJzG50F.js?D9PVtGL=a5c631
onPageFinished: url=http://railway.hinet.net/ccancel_rt.jsp
onPageStarted: url=http://railway.hinet.net/ccancel_rt.jsp?y7bRbP=VGpKrPbgT_Gvfun_k1ojGcgiy4_vWPRY
onLoadResource() url=http://railway.hinet.net/ccancel_rt.jsp?y7bRbP=VGpKrPbgT_Gvfun_k1ojGcgiy4_vWPRY
onPageFinished: url=http://railway.hinet.net/ccancel_rt.jsp?y7bRbP=VGpKrPbgT_Gvfun_k1ojGcgiy4_vWPRY
onPageStarted: url=http://railway.hinet.net/ccancel_rt.jsp?y7bRbP=VGpKrPbgTTsO9yRbWE8r.3PN0Bo5YqTE
onLoadResource() url=http://railway.hinet.net/ccancel_rt.jsp?y7bRbP=VGpKrPbgTTsO9yRbWE8r.3PN0Bo5YqTE
onLoadResource() url=http://railway.hinet.net/CssStyle/master.css
onLoadResource() url=http://railway.hinet.net/4QbVtADbnLVIc/d.FxJzG50F.js?D9PVtGL=a5c631
onLoadResource() url=http://railway.hinet.net/Images/title_08.jpg
onLoadResource() url=http://railway.hinet.net/Images/title_bg.jpg
onPageFinished: url=http://railway.hinet.net/ccancel_rt.jsp?y7bRbP=VGpKrPbgTTsO9yRbWE8r.3PN0Bo5YqTE
onLoadResource() url=http://railway.hinet.net/4QbVtADbnLVIc/jW39ezbWPr.js?65MRT9vNU1rhU6TUrOf4kG=z_qkPe3KO5xVeYHXURGyC2YnDCN9LkApa6fFzTFwRKxB8rgzZVI1f9oOmXb5gCrR4wmBCuVwxLbgQMAgUDev1iZgpQCdspYd

但是基于 4.4 和更高版本的基于 Chromium 的 webkit 的结果如下所示:

V/attlog: url=http://railway.hinet.net/ccancel_rt.jsp
W/EGL_genymotion: eglSurfaceAttrib not implemented
E/OpenGLRenderer: Getting MAX_TEXTURE_SIZE from GradienCache
E/OpenGLRenderer: MAX_TEXTURE_SIZE: 16384
E/OpenGLRenderer: Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
E/OpenGLRenderer: MAX_TEXTURE_SIZE: 16384
D/OpenGLRenderer: Enabling debug mode 0
W/AwContents: nativeOnDraw failed; clearing to background color.
W/AwContents: nativeOnDraw failed; clearing to background color.
I/chromium: [INFO:simple_index_file.cc(437)] Simple Cache Index is being restored from disk.
V/attlog: onPageStarted: url=http://railway.hinet.net/ccancel_rt.jsp
V/attlog: onLoadResource() url=http://railway.hinet.net/ccancel_rt.jsp
V/attlog: onPageFinished: url=http://railway.hinet.net/ccancel_rt.jsp
V/attlog: onLoadResource() url=http://railway.hinet.net/favicon.ico
I/chromium: [INFO:async_pixel_transfer_manager_android.cc(60)] Async pixel transfers not supported
E/chromium: [ERROR:gles2_cmd_decoder_autogen.h(1082)] [GroupMarkerNotSet(crbug.com/242999)!:884AB3B7]GL ERROR :GL_INVALID_OPERATION : GetIntegerv: <- error from previous GL command
I/chromium: [INFO:async_pixel_transfer_manager_android.cc(60)] Async pixel transfers not supported
E/chromium: [ERROR:gles2_cmd_decoder_autogen.h(1082)] [GroupMarkerNotSet(crbug.com/242999)!:4872B4B7]GL ERROR :GL_INVALID_OPERATION : GetIntegerv: <- error from previous GL command

欣赏。

4

1 回答 1

0

尝试在您的 WebView 上设置 WebChromeClient,可能是 Javascript 问题。如此处所述,不设置 WebChromeClient 未启用 Javascript 执行: 在 WebViewClient 中启用通用 JavaScript

WV_test.setWebChromeClient(new WebChromeClient());
WV_test.loadUrl(...);

这有什么改变吗?

于 2017-04-09T16:12:09.417 回答