New issue
Advanced search Search tips

Issue 854282 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Jul 12
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug



Sign in to add a comment

WebView special protocol handlers can't load .svgz files

Project Member Reported by torne@chromium.org, Jun 19

Issue description

The 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.
 
See also issue 854283 for the more general issue of using a different MIME type map than Chromium in the first place.
Labels: -Pri-3 Pri-2
Cc: changwan@chromium.org
Owner: paulmiller@chromium.org
Status: Assigned (was: Available)
Paul, could you take a look?
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.
Can't we just wrap the InputStream in an InflaterInputStream from the java stdlib to gunzip the data?
Oh neat, I didn't know about InflaterInputStream.
Project Member

Comment 7 by bugdroid1@chromium.org, 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

Status: Fixed (was: Assigned)

Sign in to add a comment