Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

Remaining delay calculation for background task is calculated from the wrong time. #1706

@couchcrew-thomas

Description

@couchcrew-thomas

Version 4.0 Snapshot

When calling a background method delayed with a delay and serial from a method entry with the same serial, the remaining delay of method delayed is calculated wrong after the execution of entry.

@Background(serial = "foo")
protected void entry() {
    long executionTime = System.currentTimeMillis();
    delayed(executionTime);
}

@Background(serial = "foo", id = "delayedTask", delay = 20000L)
protected void delayed(final long execTime) {
    boolean test = System.currentTimeMillis() - execTime >= 20000L;
    Log.d("bug", String.valueOf(test));
}

The test returns false.

This is caused by wrong calculation in BackgroundExecutor Line 429. It calculates the delay of the next task from the targetTimeMillis of the currently finishing task when it should use targetTimeMillis of the next task.

Note
I did not test the behaviour of the @UiThread executor. It could be possible the issue occurs there as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions