6

I'm using a WebView to display an SVG image in my Android app. It worked without any issues up to Chrome 71, but since the update to Chrome 72 I'm getting a parser error:

error on line 21 at column 19: AttValue: ' expected

Line 21 is this one, and column 19 is the #:

<g clip-path="url(#clip1)">

If I skip over that line, I get the same error on the next line, complaining about the #efefef:

<g fill-opacity="1" fill-rule="evenodd" stroke="none" fill="#efefef">

It appears like the # is causing some issues with Chrome 72. How can I fix that?


It seems to be a bug in Chrome. Might be somewhat related to this issue.

I'm loading the SVG with webview.loadData(svg, "image/svg+xml", "utf-8"), and if I encode the # with %23 it's working. But why would I have to encode the data by myself?

Floern
  • 33,559
  • 24
  • 104
  • 119
  • I think something seriously broke in Chrome 72, webviews do not expand height any more either. – NoBugs Feb 06 '19 at 00:30
  • May be same as this - https://blog.branch.io/ios-11-safari-view-controller-cookie-passthrough-and-the-future-of-mobile-web/. I'm getting an error similar in percentages of Mobile Safari 12.0 - `28%`, Mobile Safari 11.0 - `18%` and Chrome Mobile 72.0.3626 - `13%` out of 400 events in a single day. – gihanchanuka Mar 07 '19 at 21:20
  • @RobertLongson as stated in the question, with `webview.loadData()`, loading the plain svg code. – Floern Mar 07 '19 at 21:47
  • Chrome fixed their buggy URL parser. – Robert Longson Mar 07 '19 at 22:50
  • Apparently `loadData()` uses the `data` scheme internally (in contrary to `loadDataWithBaseURL()`), but still it doesn't make much sense that I suddenly have to encode the data myself. – Floern Mar 08 '19 at 08:31

0 Answers0