Open Bug 903575 Opened 11 years ago Updated 2 years ago

canvas element need to provide information about its visibility state

Categories

(Core :: Layout, defect)

defect

Tracking

()

People

(Reporter: yury, Unassigned)

References

Details

(Whiteboard: [shumway])

Attachments

(1 file, 1 obsolete file)

It will be nice to have an attribute (and event, if possible) for the canvas element that will indicate its visibly. A typical use case for this functionality is not to perform painting on the canvas during animation if the canvas is out-of-view.

The Page Visibility API [1] will be a good candidate for the interface for this API. The functionality can be extended to add "near" state to detect if the canvas is about to be visible (similar to the bug 689623).

The state may be polled every with requestAnimationFrame. The visibility state change event will be good to have if the visibility state property polling interval is too low, e.g. less than 1 time per second.

  [1] https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility/Overview.html
Attached patch quick hack (obsolete) — Splinter Review
Here's a quick hack to add a mozVisible attribute to canvas elements that returns true if the canvas is visible or near visible.
Would it be better to just support passing an element to requestAnimationFrame and not triggering the callback if the element is not visible?
(In reply to Vacation until Aug 19.  Do not ask for review. from comment #2)
> Would it be better to just support passing an element to
> requestAnimationFrame and not triggering the callback if the element is not
> visible?

Yeah, I just noticed the same idea in the webperf threads. We would want to continue generating frames (e.g. to execute actionscript stuff) but not paint them. In this case we would probably need to maintain the frame rate using e.g. setInterval and use requestAnimationFrame to just paint them.
How should this behave in a background tab?  Note that in background tabs requestAnimationFrame is turned off altogether, but setInterval is just throttled to 1Hz...
(In reply to Vacation until Aug 19.  Do not ask for review. from comment #4)
> How should this behave in a background tab?  Note that in background tabs
> requestAnimationFrame is turned off altogether, but setInterval is just
> throttled to 1Hz...

I guess we have to play by rules set by requestAnimationFrame or setInterval
Attached patch quick hackSplinter Review
some fixes
Assignee: nobody → tnikkel
Assignee: tnikkel → nobody
Attachment #788355 - Attachment is obsolete: true
Blocks: 927828
This is a layout feature request, not a gfx bug.
No longer blocks: 927828
No longer blocks: shumway-m4
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: