Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 693452d7e8af6e04dd3f6bd3719d91755f1de9a3
      
https://github.com/WebKit/WebKit/commit/693452d7e8af6e04dd3f6bd3719d91755f1de9a3
  Author: Chris Dumez <[email protected]>
  Date:   2026-06-13 (Sat, 13 Jun 2026)

  Changed paths:
    M Source/WebKit/UIProcess/Cocoa/ProcessAssertionCocoa.mm

  Log Message:
  -----------
  REGRESSION(235201@main): WKProcessAssertionBackgroundTaskManager can never 
cancel its pending release task
https://bugs.webkit.org/show_bug.cgi?id=316889

Reviewed by Per Arne Vollan.

-[WKProcessAssertionBackgroundTaskManager _scheduleReleaseTask] schedules a task
that releases the background assertion 2 seconds after the UI assertion's
expiration handler fires. This task is meant to be cancelled by
_cancelPendingReleaseTask when the application returns to the foreground.

235201@main ("Introduce WorkQueue::main() to get the main thread's work queue")
rewrote _scheduleReleaseTask to dispatch the work via
WorkQueue::main().dispatchAfter() instead of dispatch_block_create() +
dispatch_after(). In doing so it dropped the assignment to the
_pendingTaskReleaseTask ivar. As a result _pendingTaskReleaseTask stayed null,
so _cancelPendingReleaseTask always took its early
`if (!_pendingTaskReleaseTask) return;` path and the dispatch_block_cancel() was
never reached. The background assertion was then released ~2 seconds later even
though the app had already come back to the foreground, leaving the Web
processes unable to take foreground activities.

Restore the cancellable task by creating it with dispatch_block_create() (which
dispatch_block_cancel() requires) and storing it in _pendingTaskReleaseTask so 
it
can actually be cancelled. The block is held in an OSObjectPtr<dispatch_block_t>
that adopts the +1 returned by dispatch_block_create(), so the manual
Block_release() dance the original code needed is no longer necessary.

* Source/WebKit/UIProcess/Cocoa/ProcessAssertionCocoa.mm:
(-[WKProcessAssertionBackgroundTaskManager _scheduleReleaseTask]):
(-[WKProcessAssertionBackgroundTaskManager _cancelPendingReleaseTask]):

Canonical link: https://commits.webkit.org/315178@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to