Closed Bug 888307 Opened 6 years ago Closed 6 years ago

svg.viewbox.baseVal is null when viewBox attribute is unset since Firefox 22

Categories

(Core :: SVG, defect, critical)

22 Branch
defect
Not set
critical

Tracking

()

RESOLVED WONTFIX

People

(Reporter: joel.schaal, Unassigned)

References

()

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36

Steps to reproduce:

* go to demo-dhs.dwos.com
* login with user1:user11
* click on track



Actual results:

The corresponding view is not listed (nothing happens)


Expected results:

A view with svg icons should be listed
As additional info, we used GWT and lib-gwt-svg.jar to build our site, and this failure seem to happen right at the beginning, so I guess it should be easily reproducible, and we should not be the only ones impacted.

This is a major problem for us since our site is not browsable anymore for Firefox 22+ users (everything worked fine in Firefox 21).
Severity: normal → critical
We're really going to need a reduced testcase here. Can you produce something smaller that exhibits this bug.

Alternatively could you find a regression range using these instructions: http://mozilla.github.io/mozregression/
Flags: needinfo?(joel.schaal)
Oh and which file contains the svg.viewbox.baseVal code?
Wow, I tried the mozregression tool and it is fantastic (I suspect there is a git bisect behind, but it really works well).
The results are here :
Last good nightly: 2013-02-27
First bad nightly: 2013-02-28

I understand that my example is a bit too complicated to debug. I tried with a basic example (just a simple svg and trying to access it through javascript) but there was no problem there.

I also tried to debug on a local unobfuscated version, and we found the faulty line generated by GWT :
$setElement(this, (lRoot = dynamicCast(convert(createElementNS(lDoc.ot, 'http://www.w3.org/2000/svg', 'svg')), Q$OMSVGSVGElement) , lDefs = dynamicCast(convert(createElementNS(lDoc.ot, 'http://www.w3.org/2000/svg', 'defs')), Q$OMSVGDefsElement) , $appendChild(lRoot.ot, lDefs.ot) , mInitGradients(lDoc, lDefs) , $mCreateSymbols(lDoc, lDefs) , pReadOnly || $mCreateFilters(lDoc, lDefs) , lJawSVG = $mInitSVG_1(this.aJaw, lDoc) , lJawSVG.ot.setAttribute('transform', 'translate(0,8)') , $appendChild(lRoot.ot, lJawSVG.ot) , $setViewBox(lRoot, 0, -10, 400, 520) , $setHeight_1(lRoot, ($clinit_Style$Unit() , PX), 520) , $setWidth_2(lRoot, PX, 400) , lRoot).ot);

The call to setViewBox (at the end) is where the problem happens, and is part of the 3rd-party library :

function $setViewBox(this$static, x, y, width, height){
var viewBox;
viewBox = this$static.ot.viewBox.baseVal;
viewBox.x = x;
viewBox.y = y;
viewBox.width = width;
viewBox.height = height;
}

Here, what happens is that this$static.ot.viewBox.baseVal returns null (this$static.ot resolves to a SVGSVGElement) and then the rest fails... 

I hope this can help you guys a bit.
Flags: needinfo?(joel.schaal)
Can you send the built from ids for the last good and first bad nightlies please. One way is to run each build, type about:buildconfig in the address bar and then copy the Built from link.
OK, here is more output from mozregression from the first time :

Last good nightly: 2013-02-27
First bad nightly: 2013-02-28

Pushlog:
http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=e7632ab657e5&tochange=b0e08db3bc2a

do you want to bisect further by fetching the repository and building? (y or n) y
Building changesets:
Trunk not found.
Removed old mozbuild-trunk directory. Downloading a fresh repo from mozilla-central...
abort: No module named repo!

 Narrowed changeset range from e7632ab657e5 to b0e08db3bc2a

Time to do some bisecting and building!
Invalid values. Please check your changeset revision numbers.
If the problem persists, try running mozcommitbuilder with the -f flag.

_______________________________________________________________________


Then, the about:buildconfig for the 2013-02-27 :

Build Machine : w64-ix-slave104
Source        : Built from http://hg.mozilla.org/mozilla-central/rev/e7632ab657e5
Build platform: target i686-pc-mingw32

Build tools
  Compiler      : e:/builds/moz2_slave/m-cen-w32-ntly-000000000000000/build/obj-firefox/_virtualenv/Scripts/python.exe -O e:/builds/moz2_slave/m-cen-w32-ntly-000000000000000/build/build/cl.py cl
  Version       : 16.00.30319.01
  Compiler flags: -TC -nologo -W3 -Gy -Fdgenerated.pdb -wd4819 -we4553 -DNDEBUG -DTRIMMED -Zi -UDEBUG -DNDEBUG -GL -wd4624 -wd4952 -O1 -Oy-

  Compiler      : e:/builds/moz2_slave/m-cen-w32-ntly-000000000000000/build/obj-firefox/_virtualenv/Scripts/python.exe -O e:/builds/moz2_slave/m-cen-w32-ntly-000000000000000/build/build/cl.py cl
  Version       : 16.00.30319.01
  Compiler flags: -wd4099 -TP -nologo -W3 -Gy -Fdgenerated.pdb -wd4251 -wd4345 -wd4351 -wd4482 -wd4800 -wd4819 -we4553 -GR- -DNDEBUG -DTRIMMED -Zi -UDEBUG -DNDEBUG -GL -wd4624 -wd4952 -O1 -Oy-

Configure arguments: --enable-update-channel=nightly --enable-update-packaging --enable-jemalloc --enable-signmar --enable-profiling --enable-metro --enable-js-diagnostics --enable-warnings-as-errors

______________________________________________________________________


And finally, the about:buildconfig for the 2013-02-28 :

Build Machine : w64-ix-slave19
Source        : Built from http://hg.mozilla.org/mozilla-central/rev/b0e08db3bc2a
Build platform: target i686-pc-mingw32

Build tools
  Compiler      : e:/builds/moz2_slave/m-cen-w32-ntly-000000000000000/build/obj-firefox/_virtualenv/Scripts/python.exe -O e:/builds/moz2_slave/m-cen-w32-ntly-000000000000000/build/build/cl.py cl
  Version       : 16.00.30319.01
  Compiler flags: -TC -nologo -W3 -Gy -Fdgenerated.pdb -wd4819 -we4553 -DNDEBUG -DTRIMMED -Zi -UDEBUG -DNDEBUG -GL -wd4624 -wd4952 -O1 -Oy-

  Compiler      : e:/builds/moz2_slave/m-cen-w32-ntly-000000000000000/build/obj-firefox/_virtualenv/Scripts/python.exe -O e:/builds/moz2_slave/m-cen-w32-ntly-000000000000000/build/build/cl.py cl
  Version       : 16.00.30319.01
  Compiler flags: -wd4099 -TP -nologo -W3 -Gy -Fdgenerated.pdb -wd4251 -wd4345 -wd4351 -wd4482 -wd4800 -wd4819 -we4553 -GR- -DNDEBUG -DTRIMMED -Zi -UDEBUG -DNDEBUG -GL -wd4624 -wd4952 -O1 -Oy-

Configure arguments: --enable-update-channel=nightly --enable-update-packaging --enable-jemalloc --enable-signmar --enable-profiling --enable-metro --enable-js-diagnostics --enable-warnings-as-errors
Most likely bug 785606, in which case I think you'll need to change your code. viewBox.baseVal actually should be null if there's no viewBox defined.

Does your site work on Opera?

You could put in some viewBox to begin as an attribute on the SVG element.
You could change your code to be

function $setViewBox(this$static, x, y, width, height){
this$static.ot.setAttribute("viewBox", x + " " + y + " " + width + " " + height);
}

for instance
(In reply to Robert Longson from comment #8)
> Most likely bug 785606, in which case I think you'll need to change your
> code. viewBox.baseVal actually should be null if there's no viewBox defined.

(yeah -- from my reading of bug 785606 comment 2 - 3, it sounds like this was an expected outcome of that bug.)
Depends on: 785606
OS: Windows 7 → All
Hardware: x86_64 → All
Summary: svg.viewbox.baseVal is null since Firefox 22 → svg.viewbox.baseVal is null when viewBox attribute is unset since Firefox 22
Does work in Opera though which is strange. Could be taking a different code path there of course.
Opera does return a rect here even though it doesn't make sense. The SVG 1.2 tiny spec is explicit that null should be returned even though it's talking about its micro dom so I don't think we're going to change our implementation as it makes sense that if you don't have a viewBox, you can't get the viewBox rect.
Sorry for the delay, here are some answers :

> Does your site work on Opera?
> The SVG 1.2 tiny spec is explicit that null should be returned
Actually no, the site does not work under Opera as well, so I begin to think that the problem lies more with the library we use.
What I do not understand is why the Firefox update was the trigger. What did Firefox return in version 21 or before ?

> You could change your code to be
Well, all our code is in Java, and GWT translates it to Javascript. The part that causes the problem right now seems to be in the library (lib-gwt-svg-0.5.2.jar) since the method to set the viewBox retrieves the previous viewBox and sets each value in it. (as seen in comment #4, second snippet). 

I looked at their site, and they have already been aware of that since the bug 785606 (https://github.com/laaglu/lib-gwt-svg/commit/f7080a16fd9e0edcb43c01fe69927fe647f73f86)

So I guess I filed this bug a bit too quick... Sorry for the noise, and thank you for your help.
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → WORKSFORME
We didn't change anything on our side so the best resolution is probably WONTFIX.
Resolution: WORKSFORME → WONTFIX
In Firefox 21 when asked for the viewBox of something that didn't have a viewBox we would return zeros in all 4 fields I think. Since the code in question writes and never reads it was moot.
@Robert Longson : OK, thanks !
In Chrome, IE and Edge an unset viewBox will return rect with x, y, width and height as 0.  This way it is possible to change the view box by setting the x, y, width and height attributes on the object returned from SVGFitToViewBox.viewBox.baseVal.  Cross browser would have to use setAttribute.
Chrome, IE and Edge do not support viewBox(none) Chrome can therefore not SMIL animate something that has a viewBox into something that does not.
You need to log in before you can comment on or make changes to this bug.