Skip to content

Possible wrong timer behavoir in run_wasm.js #59666

@yurydelendik

Description

@yurydelendik

TL;DR I suspect a defect in the implementation of the addTimer code:

if (ms == 0 && !isNextTimerDue()) {

It is connected with isNextTimerDue logic: when ms == 0 and isNextTimerDue() == true, the Task.run may create two separate entries in the timerHeap (in comparison with isNextTimerDue() == false, they will be just added to zeroTimerQueue) when engine runs slow.

The flute engine produces timers with the following cadence: 16 0 0 16 0 0 .. in the scheduleFrame. The defect above causing dart benchmark to fail "Null check operator used on a null value" because the draw frame can be executed out of sequence with corresponding begin frame.

I'm temporary patching it with:

    if (ms == 0){
      if (!isNextTimerDue()) {
        zeroTimerQueue.push(f);
      } else {
        timerHeap[0].push(f); // keeps Timer.run together
      } 
    } else {

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-dart2wasmIssues for the dart2wasm compiler.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions