Skip to content

Regression in requestIdleCallback makes timeout option a no-op #57570

Description

@pakerwreah

Regression in requestIdleCallback introduced by:

The timeout is never assigned, so it is never forwarded to runtimeScheduler.

Before the PR above, it was being assigned alongside expirationTime.

With the current code the task will keep running for up to 5 minutes (default value).

std::optional<HighResDuration> timeout;
std::optional<HighResTimeStamp> expirationTime;
if (options.has_value() && options.value().timeout.has_value()) {
HighResDuration userTimeout = options.value().timeout.value();
if (userTimeout > HighResDuration::zero()) {
expirationTime = runtimeScheduler->now() + userTimeout;
}
}

if (timeout.has_value()) {
task = runtimeScheduler->scheduleIdleTask(
std::move(wrappedCallback), timeout.value());
} else {
task = runtimeScheduler->scheduleIdleTask(std::move(wrappedCallback));
}

Reproducer

#57571

The PR above also contains the fix for the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: AttentionIssues where the author has responded to feedback.Needs: ReproThis issue could be improved with a clear list of steps to reproduce the issue.

    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