WebView special protocol handlers can't load .svgz files |
||||
Issue descriptionThe implementation of AndroidProtocolHandler for the special file://android_asset/ and file://android_res/ URLs implements getMimeType just by passing the file extension to java.net.URLConnection.guessContentTypeFromName. This results in .svgz files not being supported. URLConnection is aware of this file extension and returns "image/svg+xml" as the MIME type, but nothing actually decodes the gzip encoding and the image fails to load. This works in regular file: URLs that aren't using WebView's special protocol handler because there is a special case for this specific extension that adds the gzip decoding filter: https://cs.chromium.org/chromium/src/net/url_request/url_request_file_job.cc?rcl=f7efc442c8dc9108f057144983987e74ddc6a0d4&l=190 WebView should probably do the same thing here and handle this extension as a special case.
,
Jun 19 2018
,
Jun 26 2018
Paul, could you take a look?
,
Jun 29 2018
This is awkward to support. Chrome uses GzipSourceStream, which uses SourceStream for both input and output. WebView uses InputStream and InputStreamReaderWrapper instead of SourceStream, and it's difficult to plumb between the two because the former support seeking while the latter doesn't.
,
Jul 2
Can't we just wrap the InputStream in an InflaterInputStream from the java stdlib to gunzip the data?
,
Jul 3
Oh neat, I didn't know about InflaterInputStream.
,
Jul 12
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/7a5feed58d4c2e2e8870d1dbd9e05e61039b9d27 commit 7a5feed58d4c2e2e8870d1dbd9e05e61039b9d27 Author: Paul Miller <paulmiller@google.com> Date: Thu Jul 12 18:04:43 2018 WebView: Support loading .svgz assets/resources Loading .svgz files from the web works because of a special case in URLRequestFileJob::SetUpSourceStream(). Add a special case in AndroidProtocolHandler so that e.g. WebView.loadUrl("file:///android_asset/foo.svgz") works as well. BUG= 854282 Change-Id: I995f8b602bd6e3b05818ede763f3774465850d82 Reviewed-on: https://chromium-review.googlesource.com/1134429 Reviewed-by: Richard Coles <torne@chromium.org> Commit-Queue: Paul Miller <paulmiller@chromium.org> Cr-Commit-Position: refs/heads/master@{#574634} [modify] https://crrev.com/7a5feed58d4c2e2e8870d1dbd9e05e61039b9d27/android_webview/java/src/org/chromium/android_webview/AndroidProtocolHandler.java [add] https://crrev.com/7a5feed58d4c2e2e8870d1dbd9e05e61039b9d27/android_webview/javatests/src/org/chromium/android_webview/test/AndroidProtocolHandlerTest.java [modify] https://crrev.com/7a5feed58d4c2e2e8870d1dbd9e05e61039b9d27/android_webview/test/BUILD.gn [add] https://crrev.com/7a5feed58d4c2e2e8870d1dbd9e05e61039b9d27/android_webview/test/shell/assets/star.svg [add] https://crrev.com/7a5feed58d4c2e2e8870d1dbd9e05e61039b9d27/android_webview/test/shell/assets/star.svgz
,
Jul 12
|
||||
►
Sign in to add a comment |
||||
Comment 1 by torne@chromium.org
, Jun 19 2018