RESOLVED FIXED Bug 110913
Mac: Incorrect rendering of <audio> controls
https://bugs.webkit.org/show_bug.cgi?id=110913
Summary Mac: Incorrect rendering of <audio> controls
Christian Biesinger
Reported 2013-02-26 14:55:01 PST
Attachments
Patch (2.31 KB, patch)
2013-02-26 14:57 PST, Christian Biesinger
no flags
Patch (18.96 KB, patch)
2013-02-26 15:23 PST, Christian Biesinger
no flags
Patch (26.07 KB, patch)
2013-02-26 16:35 PST, Christian Biesinger
no flags
Patch (27.66 KB, patch)
2013-02-27 13:17 PST, Christian Biesinger
no flags
Patch (27.34 KB, patch)
2013-02-27 15:02 PST, Christian Biesinger
no flags
Patch (29.24 KB, patch)
2013-02-28 13:31 PST, Christian Biesinger
no flags
Patch (28.75 KB, patch)
2013-02-28 13:43 PST, Christian Biesinger
no flags
Patch (28.18 KB, patch)
2013-03-05 18:47 PST, Christian Biesinger
no flags
Patch (27.91 KB, patch)
2013-03-11 15:11 PDT, Christian Biesinger
no flags
Patch (27.20 KB, patch)
2013-03-11 18:14 PDT, Christian Biesinger
no flags
Christian Biesinger
Comment 1 2013-02-26 14:57:53 PST
Christian Biesinger
Comment 2 2013-02-26 14:58:35 PST
This almost fixes it, but for really small <audio> elements the rendering is not correct. However, I don't understand why that is.
Christian Biesinger
Comment 3 2013-02-26 15:23:02 PST
Christian Biesinger
Comment 4 2013-02-26 16:12:10 PST
So the remaining problem is this: To completely fix this, the timeline <input> needs to also have min-width: 0; However, just adding that doesn't work because flex box still reserves space for the "current time"/"time remaining" <div>s. Those divs are a special renderer that just does setWidth(0) to hide itself when the container becomes too small. That seems to confuse the flex box layout code for some reason...
Christian Biesinger
Comment 5 2013-02-26 16:26:12 PST
OK, turns out the solution is to make RenderMediaControlTimeDisplay also override min/maxPreferredWidth and return 0 if it is collapsed.
Christian Biesinger
Comment 6 2013-02-26 16:35:15 PST
Christian Biesinger
Comment 7 2013-02-26 16:35:51 PST
Comment on attachment 190389 [details] Patch This should be all ready for review now.
Tony Chang
Comment 8 2013-02-26 16:50:40 PST
This is actually the perfect use case for visibility:collapse, but that's not implemented yet. http://dev.w3.org/csswg/css3-flexbox/#visibility-collapse https://bugs.webkit.org/show_bug.cgi?id=70782 This change seems OK to me, but Ojan may have a better idea about how to handle this without having to override minPreferredLogicalWidth/maxPreferredLogicalWidth.
Christian Biesinger
Comment 9 2013-02-26 16:52:48 PST
Ojan is OOO for the rest of the week :(
WebKit Review Bot
Comment 10 2013-02-26 18:15:17 PST
Comment on attachment 190389 [details] Patch Attachment 190389 [details] did not pass chromium-ews (chromium-xvfb): Output: http://webkit-commit-queue.appspot.com/results/16671100 New failing tests: media/media-document-audio-repaint.html
Ojan Vafai
Comment 11 2013-02-26 21:12:46 PST
Comment on attachment 190389 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=190389&action=review > Source/WebCore/rendering/RenderMediaControlElements.cpp:81 > + m_collapsed = true; I'm not sure visibility:collapse would actually fix the preferred width issue. I suppose if you set visibility:collapse *before* doing layout it would work actually. So, yeah, a FIXME to that effect would be nice. > Source/WebCore/rendering/RenderMediaControlElements.cpp:90 > +LayoutUnit RenderMediaControlTimeDisplay::minPreferredLogicalWidth() const > +{ > + if (m_collapsed) > + return 0; > + return RenderFlexibleBox::minPreferredLogicalWidth(); Ugh. I really don't like this, but I don't see an alternative either. Also, it's theoretically incorrect in some cases (e.g. when you call minPreferredLogicalWidth before doing a layout). Does the following work? -Instead of calling setWidth, *before* the RenderFlexibleBox::layout call, clear any overrideLogicalWidth and then set the *override* logical width to 0 (if the container width is to small that is). Then call RenderFlexbileBox::layout. Then you shouldn't need to override min/maxPreferred. > Source/WebCore/rendering/RenderMediaControlElements.h:54 > + virtual LayoutUnit minPreferredLogicalWidth() const; > + virtual LayoutUnit maxPreferredLogicalWidth() const; You should be able to just override computeIntrinsicLogicalWidths instead of these two. I think that would be better. > LayoutTests/ChangeLog:16 > + Regenerate test results. FWIW, in the future, no need to add comments like this. This doesn't actually explain anything (e.g. why the new results are correct).
Christian Biesinger
Comment 12 2013-02-27 12:45:26 PST
Is it a good idea to set visibility:collapse from inside a renderer, during layout...? Setting the override logical content width didn't help... should RenderFlexibleBox::mainAxisExtentForChild take into account the override width, like RenderDeprecatedFlexibleBox did? (as in contentWidthForChild)
Christian Biesinger
Comment 13 2013-02-27 13:04:55 PST
Overriding computeIntrinsicLogicalWidths didn't work either (as a sidenote, I don't understand why this class inherits from RenderFlexibleBox, as opposed to RenderBlock)
Christian Biesinger
Comment 14 2013-02-27 13:17:59 PST
Christian Biesinger
Comment 15 2013-02-27 13:20:02 PST
In this patch, instead of overriding the functions, I just set m_min|maxPreferredLogicalWidth to zero in layout().
WebKit Review Bot
Comment 16 2013-02-27 14:05:25 PST
Comment on attachment 190586 [details] Patch Attachment 190586 [details] did not pass chromium-ews (chromium-xvfb): Output: http://webkit-commit-queue.appspot.com/results/16672484 New failing tests: media/media-document-audio-repaint.html
Tony Chang
Comment 17 2013-02-27 14:26:13 PST
Comment on attachment 190586 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=190586&action=review > Source/WebCore/ChangeLog:29 > + Override minPreferredLogicalWidth and maxPreferredLogicalWidth to return 0 if we're collapsed. > + Add a m_collapsed member to indicate if we are collapsed. This text is out of date. > Source/WebCore/rendering/RenderMediaControlElements.cpp:80 > setWidth(0); > + m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = 0; This looks better.
Christian Biesinger
Comment 18 2013-02-27 14:59:56 PST
(In reply to comment #16) > New failing tests: > media/media-document-audio-repaint.html I can't reproduce this failure locally.... I'll update the changelog.
Christian Biesinger
Comment 19 2013-02-27 15:02:38 PST
WebKit Review Bot
Comment 20 2013-02-27 16:55:28 PST
Comment on attachment 190611 [details] Patch Attachment 190611 [details] did not pass chromium-ews (chromium-xvfb): Output: http://webkit-commit-queue.appspot.com/results/16829158 New failing tests: media/media-document-audio-repaint.html
Ojan Vafai
Comment 21 2013-02-27 23:35:17 PST
(In reply to comment #13) > Overriding computeIntrinsicLogicalWidths didn't work either > > (as a sidenote, I don't understand why this class inherits from RenderFlexibleBox, as opposed to RenderBlock) I think it's just for centering. A perfect example of why we need to implement the alignment APIs for other display types. It's silly to use flexbox just to get vertical centering. (In reply to comment #12) > Is it a good idea to set visibility:collapse from inside a renderer, during layout...? > > > Setting the override logical content width didn't help... should RenderFlexibleBox::mainAxisExtentForChild take into account the override width, like RenderDeprecatedFlexibleBox did? (as in contentWidthForChild) Yes, I think that's right. It's a little gross to spread override sizes to other parts of the code, but I think that's better (and more correct) than messing with preferred sizes during layout. I'm OK with this patch going in as is so we can get the regression fixed, but I'd like to see the override thing done if possible.
Ojan Vafai
Comment 22 2013-02-27 23:36:06 PST
Also, looks like there's a Chromium linux failure. I'm sure it just needs a rebaseline, but maybe add it to TestExpectations so the tree doesn't turn red when you commit this?
Build Bot
Comment 23 2013-02-28 08:34:01 PST
Comment on attachment 190611 [details] Patch Attachment 190611 [details] did not pass mac-ews (mac): Output: http://webkit-commit-queue.appspot.com/results/16782414 New failing tests: media/nodesFromRect-shadowContent.html
Build Bot
Comment 24 2013-02-28 08:55:59 PST
Comment on attachment 190611 [details] Patch Attachment 190611 [details] did not pass mac-ews (mac): Output: http://webkit-commit-queue.appspot.com/results/16824066 New failing tests: media/nodesFromRect-shadowContent.html
Ojan Vafai
Comment 25 2013-02-28 10:32:31 PST
(In reply to comment #24) > (From update of attachment 190611 [details]) > Attachment 190611 [details] did not pass mac-ews (mac): > Output: http://webkit-commit-queue.appspot.com/results/16824066 > > New failing tests: > media/nodesFromRect-shadowContent.html Looks like there's a Mac failure as well. Again, probably just needs rebaseline?
Christian Biesinger
Comment 26 2013-02-28 13:26:35 PST
So, on the test failures. Mac: I can reproduce it locally, but only sometimes. I have no idea why this test failure it happens - nodesFromRect sometimes returns an additional node? When I tried to find out which node, I was unable to reproduce this failure again. (Note: not a render tree test, so rebaselining is not an issue for this one) Linux/Chrome: This failure I can usually reproduce with run-webkit-test, but not when I run in the debugger or in the actual browser. When it happens, it does have actual wrong layout though. I guess I mark the tests as flaky and hope the problems go away when I make the switch to use override widths...?
Christian Biesinger
Comment 27 2013-02-28 13:31:58 PST
Christian Biesinger
Comment 28 2013-02-28 13:43:44 PST
Tony Chang
Comment 29 2013-03-01 08:30:50 PST
(In reply to comment #26) > Linux/Chrome: This failure I can usually reproduce with run-webkit-test, but not when I run in the debugger or in the actual browser. When it happens, it does have actual wrong layout though. Does the failure happen if you run "DumpRenderTree /path/to/LayoutTests/media/media-document-audio-repaint.html"? If so, you can run gdb against DumpRenderTree directly (make sure to pass --no-timeout).
Christian Biesinger
Comment 30 2013-03-01 08:32:22 PST
(In reply to comment #29) > (In reply to comment #26) > > Linux/Chrome: This failure I can usually reproduce with run-webkit-test, but not when I run in the debugger or in the actual browser. When it happens, it does have actual wrong layout though. > > Does the failure happen if you run "DumpRenderTree /path/to/LayoutTests/media/media-document-audio-repaint.html"? If so, you can run gdb against DumpRenderTree directly (make sure to pass --no-timeout). I did try "gdb DumpRenderTree /path/to/LayoutTests/media/media-document-audio-repaint.html" which didn't reproduce the problem. I did not try running DRT directly without gdb, maybe that's worth a try...
Christian Biesinger
Comment 31 2013-03-05 17:46:59 PST
Comment on attachment 190799 [details] Patch After spending some time looking at this with Ojan, the fix seems to be to specify min-width: 0 in the CSS instead of changing the C++ code. That works because then, RenderFlexibleBox will not call maxPreferredContentWidth, so everything should be fine. I'll test that and upload a patch with that.
Christian Biesinger
Comment 32 2013-03-05 18:42:57 PST
It does fix the bug. But nodesFromRect-shadow.html is now consistently failing - it looks like hit testing finds a shadow input element even when passing false for shadow content?! Also, it doesn't find the timeline container element in the shadow content, which is a little weird too... I guess I'll attach what I have
Christian Biesinger
Comment 33 2013-03-05 18:47:14 PST
Build Bot
Comment 34 2013-03-06 00:15:59 PST
Comment on attachment 191634 [details] Patch Attachment 191634 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-commit-queue.appspot.com/results/17082130 New failing tests: media/nodesFromRect-shadowContent.html
Build Bot
Comment 35 2013-03-06 13:25:11 PST
Comment on attachment 191634 [details] Patch Attachment 191634 [details] did not pass mac-ews (mac): Output: http://webkit-commit-queue.appspot.com/results/17062089 New failing tests: media/nodesFromRect-shadowContent.html editing/selection/selection-modify-crash.html
Christian Biesinger
Comment 36 2013-03-08 13:56:35 PST
hm... for nodesFromRect-shadowContent.html, there's two levels of shadow content. The <video> has an <input> in its shadow content, and then the <input> has additional shadow content. The hit test finds something in the <input>'s content, and we add its deprecatedShadowAncestorNode() to the result. Sadly, that node is the <input>, but it itself is shadow content. But I don't know how this is supposed to work...
Christian Biesinger
Comment 37 2013-03-08 17:19:08 PST
Dimitri: see previous comment - is the code in HitTestResult::addNodeToRectBasedTestResult correct when there's nested shadow content? Should this line be a loop? 560 node = node->deprecatedShadowAncestorNode();
Dimitri Glazkov (Google)
Comment 38 2013-03-09 08:54:48 PST
(In reply to comment #37) > Dimitri: see previous comment - is the code in HitTestResult::addNodeToRectBasedTestResult correct when there's nested shadow content? Should this line be a loop? > 560 node = node->deprecatedShadowAncestorNode(); That shouldn't matter, not in this case. The whole optional skipping of the shadow content for hit testing logic was added a while back in bug 80847, and I still don't understand why it's necessary.
Eric Carlson
Comment 39 2013-03-11 11:15:21 PDT
Christian Biesinger
Comment 40 2013-03-11 12:18:38 PDT
(In reply to comment #38) > (In reply to comment #37) > > Dimitri: see previous comment - is the code in HitTestResult::addNodeToRectBasedTestResult correct when there's nested shadow content? Should this line be a loop? > > 560 node = node->deprecatedShadowAncestorNode(); > > That shouldn't matter, not in this case. The whole optional skipping of the shadow content for hit testing logic was added a while back in bug 80847, and I still don't understand why it's necessary. The problem in this case is that we don't skip shadow content when we should... nodesFromRect is returning shadow content even when allowShadowContent=false. And it seems like the proximate cause of this is a nested shadow tree
Dimitri Glazkov (Google)
Comment 41 2013-03-11 13:17:33 PDT
(In reply to comment #40) > (In reply to comment #38) > > (In reply to comment #37) > > > Dimitri: see previous comment - is the code in HitTestResult::addNodeToRectBasedTestResult correct when there's nested shadow content? Should this line be a loop? > > > 560 node = node->deprecatedShadowAncestorNode(); > > > > That shouldn't matter, not in this case. The whole optional skipping of the shadow content for hit testing logic was added a while back in bug 80847, and I still don't understand why it's necessary. > > The problem in this case is that we don't skip shadow content when we should... nodesFromRect is returning shadow content even when allowShadowContent=false. > > And it seems like the proximate cause of this is a nested shadow tree Got it. Yes, the node->deprecatedShadowAncestorNode() is the wrong way to get to the first non-shadow tree node. The proper way would be to iterate through nested tree scopes until you hit Document, and then return the host of the previous tree scope. I don't think it's a big deal though. This API isn't exposed to the Web and is only used for testing.
Christian Biesinger
Comment 42 2013-03-11 13:26:22 PDT
Hm... OK. I guess I'll figure out a way to fix this failing unit test without touching HitTestResult (the caller of deprecatedShadowAncestorNode in this case)
Christian Biesinger
Comment 43 2013-03-11 13:37:10 PDT
Although... why wouldn't this also be an issue with document.elementFromPoint? We expose that to web content today.
Christian Biesinger
Comment 44 2013-03-11 14:00:36 PDT
dglazkov explained on irc. My strategy now is to fix the shadow bug separately and then commit this.
Christian Biesinger
Comment 45 2013-03-11 14:41:00 PDT
bug 112068 will fix the shadow content bug, once that's committed the test here should pass.
Christian Biesinger
Comment 46 2013-03-11 15:11:57 PDT
Created attachment 192571 [details] Patch Alternatively, this version of the patch changes the testcase such that it passes even without that other patch. Attaching in hopes of getting this regression fixed sooner.
Christian Biesinger
Comment 47 2013-03-11 18:14:06 PDT
Created attachment 192612 [details] Patch Dependency got fixed, this should pass all tests now.
Build Bot
Comment 48 2013-03-12 07:50:07 PDT
Comment on attachment 192612 [details] Patch Attachment 192612 [details] did not pass mac-ews (mac): Output: http://webkit-commit-queue.appspot.com/results/17060709 New failing tests: editing/selection/selection-modify-crash.html
Christian Biesinger
Comment 49 2013-03-12 14:05:08 PDT
Comment on attachment 192612 [details] Patch The test passes locally for me, and also passed on mac-wk2. It also doesn't use <video> or <audio>. Going to assume it is unrelated.
WebKit Review Bot
Comment 50 2013-03-12 14:55:32 PDT
Comment on attachment 192612 [details] Patch Clearing flags on attachment: 192612 Committed r145588: <http://trac.webkit.org/changeset/145588>
WebKit Review Bot
Comment 51 2013-03-12 14:55:38 PDT
All reviewed patches have been landed. Closing bug.
Jer Noble
Comment 52 2013-03-25 14:38:46 PDT
This commit broke the "current time" and "remaining time" display in mac inline controls. The new LayoutTests/platform/mac/media/audio-controls-rendering-expected.txt results are giving false-pass, as those two controls were incorrectly removed from the expected results. If this does not get fixed soon, I'm going to have to roll this entire patch back out.
Christian Biesinger
Comment 53 2013-03-25 17:35:38 PDT
I give up. This is really tricky to fix and will need more time. Jer, I don't have commit access - could you roll out this patch and bug 109775's patch while I figure out a better fix locally?
Jer Noble
Comment 54 2013-03-25 22:29:43 PDT
(In reply to comment #53) > I give up. This is really tricky to fix and will need more time. > > Jer, I don't have commit access - could you roll out this patch and bug 109775's patch while I figure out a better fix locally? FYI, you can get the sherrifbot to roll out any patch by asking in IRC (see: http://trac.webkit.org/wiki/Keeping%20the%20Tree%20Green). Anyone can cq+ the resulting patch. I'll start the ball rolling (hah!).
Jer Noble
Comment 55 2013-03-26 17:20:20 PDT
Turns out rolling out these patches is more difficult than just fixing the bug. Filed bug 113355 to track the fix.
Christian Biesinger
Comment 56 2013-04-03 15:15:56 PDT
fixed in the bug mentioned in the last comment
Note You need to log in before you can comment on or make changes to this bug.