Skip to content

Timers are never called back in the background. #6

Closed

Description

@mbostock

Related d3/d3#2211 d3/d3-transition#29.

In some browsers, requestAnimationFrame is paused in background tabs. However, setTimeout and setInterval may continue, albeit possibly throttled. This asymmetrical behavior can have undesired side-effects, such as an ever-growing timer queue that is never flushed because timers are being scheduled but never invoked.

One way to fix this might be to guarantee that the first tick of a scheduled, eligible timer is invoked after at most one second, even in a background tab, by using setTimeout or setInterval internally rather than relying solely on requestAnimationFrame. We could guarantee that timers receive at least one tick per second this way, but I think it would be sufficient to only have this special behavior for the first tick—it’s nice if we do as little as possible in the background.

Or, we could just tick at least once per second, no matter what.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions