MozAfterPaint handlers should only fire after the next layer transaction by default

RESOLVED DUPLICATE of bug 1302071

Status

()

defect
P3
normal
RESOLVED DUPLICATE of bug 1302071
2 years ago
2 years ago

People

(Reporter: mconley, Unassigned)

Tracking

(Blocks 1 bug)

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [gfx-noted])

I believe the way MozAfterPaint works is that it fires after a composite has occurred for the window that the listener is attached to.

Usually, this is fine - we attach a MozAfterPaint listener, eventually do something that should cause a paint, the layer transaction occurs, the composite occurs, and then our MozAfterPaint listener fires as intended.

That's the expected case. Here's an unexpected case:

Something (X) that we don't care about triggers a paint. A layer transaction occurs for X. Then our MozAfterPaint event listener is attached. We do something that we care about that triggers another paint (Y). A layer transaction occurs for Y. A composite occurs for X, and our MozAfterPaint event listener fires early.

This sort of bug has cropped up before in our Talos tests. I originally worked around this in bug 1264409 by adding a transactionId on the MozAfterPaint event that can be compared against the last transaction ID that was used (see my mailing list post that I sent after landing bug 1264409 here: https://groups.google.com/forum/#!searchin/mozilla.dev.platform/lastTransactionId%7Csort:relevance/mozilla.dev.platform/pCLwWdYc_GY/j9A-vWm3AgAJ).

I think there might be a better solution that puts less onus on the writer of the MozAfterPaint event handler.

Specifically, what I suggest is that when we attach a MozAfterPaint listener, we map that listener to the last transaction ID used for that window. When a composite occurs, and we go through each of the MozAfterPaint listeners, we should only fire the ones for layer transactions that have IDs that are greater than what we'd stored.

Does this sound feasible? Any glaring problems with the idea?
Flags: needinfo?(matt.woodrow)
See Also: → 1339317
Seems pretty reasonable to me!

We might have tests depending on the old behaviour, but those should be fixed regardless.
Flags: needinfo?(matt.woodrow)
Whiteboard: [gfx-noted]
Blocks: 1395971
Blocks: 1415065
(In reply to Mike Conley (:mconley) (:⚙️) - Backlogged on reviews and needinfos from comment #0)
> I think there might be a better solution that puts less onus on the writer
> of the MozAfterPaint event handler.
> 
> Specifically, what I suggest is that when we attach a MozAfterPaint
> listener, we map that listener to the last transaction ID used for that
> window. When a composite occurs, and we go through each of the MozAfterPaint
> listeners, we should only fire the ones for layer transactions that have IDs
> that are greater than what we'd stored.
> 

I think this solution has already fixed in bug 1302071[1]. So I marked this as duplicate.

[1] https://hg.mozilla.org/mozilla-central/rev/a535bf3bfff1
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1302071
No longer blocks: 1419226
You need to log in before you can comment on or make changes to this bug.