src/service/vsync-impl.js
/**
   * Runs all scheduled tasks. This is typically called in an RAF
   * callback. Tests may call this method to force execution of
   * tasks without waiting.
   * @private
   */
Runs all scheduled tasks. This is typically called in an RAF
callback. Tests may call this method to force execution of
tasks without waiting.
@private
Runs all scheduled tasks . This is typically called in an RAF callback . Tests may call this method to force execution of tasks without waiting . @private
runScheduledTasks_() {
    this.backupPass_.cancel();
    this.scheduled_ = false;
    this.jankMeter_.onRun();
    const tasks = this.tasks_;
    const states = this.states_;
    const resolver = this.nextFrameResolver_;
    this.nextFrameResolver_ = null;
    this.nextFramePromise_ = null;
    this.tasks_ = this.nextTasks_;
    this.states_ = this.nextStates_;
    for (let i = 0; i < tasks.length; i++) {
      if (tasks[i].measure) {
        if (!callTaskNoInline(tasks[i].measure, states[i])) {
          tasks[i].mutate = undefined;
        }
      }
    }
    for (let i = 0; i < tasks.length; i++) {
      if (tasks[i].mutate) {
        callTaskNoInline(tasks[i].mutate, states[i]);
      }
    }
    this.nextTasks_ = tasks;
    this.nextStates_ = states;
    this.nextTasks_.length = 0;
    this.nextStates_.length = 0;
    if (resolver) {
      resolver();
    }
  }
runScheduledTasks_ ( ) { this . backupPass_ . cancel ( ) ; this . scheduled_ = false ; this . jankMeter_ . onRun ( ) ; const tasks = this . tasks_ ; const states = this . states_ ; const resolver = this . nextFrameResolver_ ; this . nextFrameResolver_ = null ; this . nextFramePromise_ = null ; this . tasks_ = this . nextTasks_ ; this . states_ = this . nextStates_ ; for ( let i = 0 ; i < tasks . length ; i ++ ) { if ( tasks [ i ] . measure ) { if ( ! callTaskNoInline ( tasks [ i ] . measure , states [ i ] ) ) { tasks [ i ] . mutate = undefined ; } } } for ( let i = 0 ; i < tasks . length ; i ++ ) { if ( tasks [ i ] . mutate ) { callTaskNoInline ( tasks [ i ] . mutate , states [ i ] ) ; } } this . nextTasks_ = tasks ; this . nextStates_ = states ; this . nextTasks_ . length = 0 ; this . nextStates_ . length = 0 ; if ( resolver ) { resolver ( ) ; } }
Runs all scheduled tasks.
Runs all scheduled tasks .
// Double buffering // Ensure that the mutate is not executed when measure fails. // Swap last arrays into double buffer.