Compositing of WebGL canvases on B2G intermittently flickers / disappears

RESOLVED FIXED in mozilla18

Status

()

defect
RESOLVED FIXED
7 years ago
7 years ago

People

(Reporter: bjacob, Assigned: bjacob)

Tracking

unspecified
mozilla18
ARM
Gonk (Firefox OS)
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(3 attachments)

Happens on most WebGL pages, e.g. 
http://people.mozilla.org/~bjacob/webgl-spotlight-js-2012/webgltriangle.html

When it disappears, panning around usually makes it reapper. When that doesn't work, the likely cause is one's running into bug 782785 instead.
Component: Canvas: WebGL → Graphics
OS: Linux → Gonk
Hardware: x86_64 → ARM
To understand why there is sometimes flickering while panning around on the page in comment 0, I put a printf in BasicCanvasLayer::UpdateSurface and in WebGLContext::GetCanvasLayer.

Notice that this page renders once and never again afterwards.

When panning around works fine, these functions don't get called.

When flickering occurs, these functions get called.

In the situation when one is panning around a canvas that hasn't been changed since the last compositing, when should / shouldn't these functions be called?
stack trace to these updatesurface calls:

#0  mozilla::layers::BasicCanvasLayer::UpdateSurface (this=0x4419e9e0, 
    aDestSurface=0x44e85f40, aMaskLayer=0x0)
    at /hack/b2g/B2G/gecko/gfx/layers/basic/BasicCanvasLayer.cpp:123
#1  0x41a1ae3a in mozilla::layers::BasicShadowableCanvasLayer::Paint (this=0x4419e9e0, 
    aContext=0x4587ca90, aMaskLayer=0x0)
    at /hack/b2g/B2G/gecko/gfx/layers/basic/BasicCanvasLayer.cpp:450
#2  0x41a1779e in mozilla::layers::BasicLayerManager::PaintLayer (this=0x44cd8740, 
    aTarget=0x4587ca90, aLayer=0x4419e9e0, 
    aCallback=0x4069abc1 <mozilla::FrameLayerBuilder::DrawThebesLayer(mozilla::layers::ThebesLayer*, gfxContext*, nsIntRegion const&, nsIntRegion const&, void*)>, 
    aCallbackData=0xbee7a50c, aReadback=0xbee79f6c)
    at /hack/b2g/B2G/gecko/gfx/layers/basic/BasicLayerManager.cpp:842
#3  0x41a17830 in mozilla::layers::BasicLayerManager::PaintLayer (this=0x44cd8740, 
    aTarget=0x4587ca90, aLayer=0x44c8ec00, 
    aCallback=0x4069abc1 <mozilla::FrameLayerBuilder::DrawThebesLayer(mozilla::layers::ThebesLayer*, gfxContext*, nsIntRegion const&, nsIntRegion const&, void*)>, 
    aCallbackData=0xbee7a50c, aReadback=0x0)
    at /hack/b2g/B2G/gecko/gfx/layers/basic/BasicLayerManager.cpp:855
#4  0x41a162b8 in mozilla::layers::BasicLayerManager::EndTransactionInternal (
    this=0x44cd8740, 
    aCallback=0x4069abc1 <mozilla::FrameLayerBuilder::DrawThebesLayer(mozilla::layers::ThebesLayer*, gfxContext*, nsIntRegion const&, nsIntRegion const&, void*)>, 
    aCallbackData=0xbee7a50c, aFlags=mozilla::layers::LayerManager::END_NO_COMPOSITE)
    at /hack/b2g/B2G/gecko/gfx/layers/basic/BasicLayerManager.cpp:474
#5  0x41a15d38 in mozilla::layers::BasicLayerManager::EndTransaction (this=0x44cd8740, 
    aCallback=0x4069abc1 <mozilla::FrameLayerBuilder::DrawThebesLayer(mozilla::layers::ThebesLayer*, gfxContext*, nsIntRegion const&, nsIntRegion const&, void*)>, 
    aCallbackData=0xbee7a50c, aFlags=mozilla::layers::LayerManager::END_NO_COMPOSITE)
    at /hack/b2g/B2G/gecko/gfx/layers/basic/BasicLayerManager.cpp:399
#6  0x41a182c4 in mozilla::layers::BasicShadowLayerManager::EndTransaction (
    this=0x44cd8740, 
    aCallback=0x4069abc1 <mozilla::FrameLayerBuilder::DrawThebesLayer(mozilla::layers::ThebesLayer*, gfxContext*, nsIntRegion const&, nsIntRegion const&, void*)>, 
    aCallbackData=0xbee7a50c, aFlags=mozilla::layers::LayerManager::END_NO_COMPOSITE)
    at /hack/b2g/B2G/gecko/gfx/layers/basic/BasicLayerManager.cpp:1053
#7  0x406e14c6 in nsDisplayList::PaintForFrame (this=0xbee7a8f0, aBuilder=0xbee7a50c, 
    aCtx=0x0, aForFrame=0x450c6418, aFlags=13)
    at /hack/b2g/B2G/gecko/layout/base/nsDisplayList.cpp:1038
#8  0x406e0fd4 in nsDisplayList::PaintRoot (this=0xbee7a8f0, aBuilder=0xbee7a50c, 
    aCtx=0x0, aFlags=13) at /hack/b2g/B2G/gecko/layout/base/nsDisplayList.cpp:938
#9  0x40709bf2 in nsLayoutUtils::PaintFrame (aRenderingContext=0x0, aFrame=0x450c6418, 
    aDirtyRegion=..., aBackstop=4294967295, aFlags=772)
This fixes it here.
Attachment #654381 - Flags: review?(bgirard)
Attachment #654381 - Flags: review?(bgirard) → review+
http://hg.mozilla.org/integration/mozilla-inbound/rev/156eaa94f73c
Assignee: nobody → bjacob
Target Milestone: --- → mozilla17
backed out in c95b9d40a173 for reftest failure
Still reftest failure. The failures are that nothing gets drawn. BenWa, do you understand why even the smaller patch https://hg.mozilla.org/try/rev/d87960507531 would have this effect?
We still dont understand the central issue here: why would these repaints cause flickering?
OK, this seems to work: just the Shadowable part is enough to fix the flickering on B2G, and does not affect desktop linux. Too bad that we still don't understand the reason why painting causes flickering, but at least a fix is in sight...
https://tbpl.mozilla.org/?tree=Try&rev=76372e01ba2f
Attachment #655612 - Flags: review?(bgirard)
Comment on attachment 654381 [details] [diff] [review]
avoid UpdateSurface of non-dirty canvases

Review of attachment 654381 [details] [diff] [review]:
-----------------------------------------------------------------

::: gfx/layers/basic/BasicCanvasLayer.cpp
@@ +228,5 @@
>  
>  void
>  BasicCanvasLayer::Paint(gfxContext* aContext, Layer* aMaskLayer)
>  {
> +  if (!mDirty)

I missed this but this change is certainly wrong. We want to paint the layer but we do want to skip the UpdateSurface below if we're not dirty.
Attachment #654381 - Flags: review+ → review-
Comment on attachment 655612 [details] [diff] [review]
just the Shadowable part

I'm fine with this change but I think I found the problem in your original patch.
Attachment #655612 - Flags: review?(bgirard) → review+
Attachment #655671 - Flags: review?(bgirard)
Attachment #655671 - Flags: review?(bgirard) → review+
\o/ Passes try
Target Milestone: mozilla17 → mozilla18
Is Gecko 17 still the target for the initial B2G release? If yes, we need aurora approval.
https://hg.mozilla.org/mozilla-central/rev/d63bb4e02b3d
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.