Skip to content

Use "requestIdleCallback" for tile processing #1547

Description

@gkjohnson

Related to #1407

Some tasks are time-sliced over multiple frames to split up the work and keep the frame rate up:

  • PriorityQueue
    • Tiling content downloading, parsing, preprocessing
    • Image overlay processing
  • QueryManager
    • Time slice point settling per frame
  • LRUCache
    • Used for unloading TilesRendererBase tiles
    • Used for unloading data in UnloadTilesPlugin

This work could be more quickly completed if we allow for it to run in an idle callback for a fixed amount of time. This would require adjusting PriorityQueue and LRUCache to be able to run for a fixed amount of time in addition to optionally iterating over a fixed amount of items (timing can possibly default to Infinity?) so we can take advantage of idle time. One caveat is that it's not supported in Safari:

requestIdleCallback( idle => {

  // run for the provided idle time
  const runTime = idle.timeRemaining();
  queue.tryRunJobs( runTime );

  // schedule idle callback again until work is complete?

} );

Perhaps a utility function can be written that can schedule frame work in addition to idle callback? This can't replace the rAF because we still need a guaranteed processing on the next frame.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions