Ticket #2402 (closed feature: fixed)

Opened 3 years ago

Last modified 3 years ago

graphicName SVG rendering issues in some Safari and Chrome versions

Reported by: ahocevar Owned by: ahocevar
Priority: major Milestone: 2.9 Release
Component: Renderer.SVG Version: 2.8
Keywords: Cc:
State: Complete

Description

Related webkit bug:  https://bugs.webkit.org/show_bug.cgi?id=33322

A workaround is to not use defs/use with the webkit versions in question. The attached patch introduces a workaround.

Please review.

Attachments

openlayers-2402.patch Download (3.5 KB) - added by ahocevar 3 years ago.
openlayers-2402.2.patch Download (3.5 KB) - added by ahocevar 3 years ago.
new patch fixing the target.parentNode issue reported by crschmidt
openlayers-2402.3.patch Download (1.2 KB) - added by ahocevar 3 years ago.
fixed rotation issue

Change History

Changed 3 years ago by ahocevar

Changed 3 years ago by ahocevar

new patch fixing the target.parentNode issue reported by crschmidt

Changed 3 years ago by crschmidt

  • state set to Commit

Changed 3 years ago by ahocevar

  • status changed from new to closed
  • state changed from Commit to Complete
  • resolution set to fixed

(In [9937]) workaround for webkit versions that have problems with defs/use. r=crschmidt (closes #2402)

Changed 3 years ago by fredj

(In [9946]) fix tests for buggy webkit. (see #2402)

Changed 3 years ago by ahocevar

fixed rotation issue

Changed 3 years ago by ahocevar

  • status changed from closed to reopened
  • state changed from Complete to Review
  • resolution fixed deleted

It turned out that not all WebKit versions that cannot use defs can rotate svg elements. The attached patch also fixes this issue, and rotation is now back for all WebKit versions.

Tests still pass, please review.

Changed 3 years ago by tschaub

  • state changed from Review to Commit

Code looks good. I'm trusting that the example works in the target browser (don't have it right now).

One minor suggestion: I don't think we should use things like OpenLayers.String.format internally unless we absolutely need to. You could argue that it improves readability, but in particularly hot areas of the library, I think it makes sense to pick performance first. While the own time of that chunk of code is low compared to the rendering time of a single node, concatenation is about 10 times faster than OpenLayers.String.format.

var style = {
    rotation: 45
};
var pos = {
    x: 2, y: 3
};

var i, str, len = 10000;

var loopStart = new Date();
for (i=0; i<len; ++i) {}
var loopElapsed = new Date() - loopStart;

var formatStart = new Date();
for (i=0; i<len; ++i) {
    str = OpenLayers.String.format(
        "rotate(${0} ${1} ${2})",
        [style.rotation, pos.x, pos.y]
    );
}
var formatElapsed = new Date() - formatStart - loopElapsed;

var concatStart = new Date();

for (i=0; i<len; ++i) {
    str = "rotate(" + style.rotation + " " + pos.x + " " + pos.y + ")";
}
var concatElapsed = new Date() - concatStart - loopElapsed;


console.log(formatElapsed / len, concatElapsed / len);

Anyway, thanks for all the bug hunting on this.

Changed 3 years ago by ahocevar

  • status changed from reopened to closed
  • state changed from Commit to Complete
  • resolution set to fixed

(In [9953]) fixed rotation for browsers that don't support defs/use. Committed version modified from patch version as suggested by tschaub. r=tschaub (closes #2402)

Note: See TracTickets for help on using tickets.