Closed Bug 1251257 Opened 8 years ago Closed 8 years ago

CanvasClient updates are racy

Categories

(Core :: Graphics: Layers, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: nical, Unassigned)

References

Details

(Whiteboard: [gfx-noted])

Attachments

(1 file)

Attached file canvas-synchro.html
CanvasClient copies the canvas's content into the same TextureCLient every frame and sends it over to the compositor in async transactions. Since there is no synchronization involved, copying frame N+1 can happen while the compositor is uploading it to a texture which is bad. The attached testcase shows a canvas changing color rapidly along with the page's background color. On Linux you can definitely see that the canvas and the content are out of sync. I haven't tested on other platforms bit i expect the result to be the same.
Whiteboard: [gfx-noted]
Hm. I thought that adding the flag IMMEDIATE_UPLOAD to the textures created by the CanvasClient would fix the issue if the texture has an intermediate buffer (should make the transaction synchronous and upload in the transaction) but it didn't do the job.

By the way, to reproduce the issue with the testcase, you should try with a release build, not a debug build.
I saw the problem on windows and linux. I did not see the problem on android and b2g.
(In reply to Nicolas Silva [:nical] (PTO until March 7th) from comment #1)
> Hm. I thought that adding the flag IMMEDIATE_UPLOAD to the textures created
> by the CanvasClient would fix the issue if the texture has an intermediate
> buffer (should make the transaction synchronous and upload in the
> transaction) but it didn't do the job.
> 
> By the way, to reproduce the issue with the testcase, you should try with a
> release build, not a debug build.

I don't think IMMEDIATE_UPLOAD forces the transaction to be sync, it only makes us upload during the transaction callback (instead of at composite time).

That may be a bug, I'm not sure if IMMEDIATE_UPLOAD is particularly useful without that property. It seems valuable to decide what behaviour we want and make sure that actually happens.

We really want to avoid sync transactions though, so maybe we should fix this another way?
(In reply to Matt Woodrow (:mattwoodrow) from comment #3)
> (In reply to Nicolas Silva [:nical] (PTO until March 7th) from comment #1)
> > Hm. I thought that adding the flag IMMEDIATE_UPLOAD to the textures created
> > by the CanvasClient would fix the issue if the texture has an intermediate
> > buffer (should make the transaction synchronous and upload in the
> > transaction) but it didn't do the job.
> > 
> > By the way, to reproduce the issue with the testcase, you should try with a
> > release build, not a debug build.
> 
> I don't think IMMEDIATE_UPLOAD forces the transaction to be sync, it only
> makes us upload during the transaction callback (instead of at composite
> time).

It tries to, at least, here: https://dxr.mozilla.org/mozilla-central/rev/be593a64d7c6a826260514fe758ef32a6ee580f7/gfx/layers/ipc/ShadowLayers.cpp#417


> We really want to avoid sync transactions though, so maybe we should fix
> this another way?

The better way to fix this would be reviving bug 1167235, but it'd be good to have a short-term solution in the mean time.
Blocks: 1252275
Blocks: 1253386
This is fixed now (either by bug 1167235, or some earlier change).
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: