[webkit-changes] [WebKit/WebKit] e604d7: PDFPlugin hangs in deallocation when data load con...

Chris Dumez noreply at github.com
Tue Mar 5 12:52:30 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: e604d7c70127a9d0abd95421c65a2ca594df690e
      https://github.com/WebKit/WebKit/commit/e604d7c70127a9d0abd95421c65a2ca594df690e
  Author: Chris Dumez <cdumez at apple.com>
  Date:   2024-03-05 (Tue, 05 Mar 2024)

  Changed paths:
    A LayoutTests/compositing/plugins/pdf/pdf-plugin-hang-during-destruction-expected.txt
    A LayoutTests/compositing/plugins/pdf/pdf-plugin-hang-during-destruction.html
    M Source/WebKit/WebProcess/Plugins/PDF/PDFIncrementalLoader.h
    M Source/WebKit/WebProcess/Plugins/PDF/PDFIncrementalLoader.mm

  Log Message:
  -----------
  PDFPlugin hangs in deallocation when data load contends with waiting for thread completion
https://bugs.webkit.org/show_bug.cgi?id=246454
rdar://101147811

Reviewed by Tim Horton.

When `PDFPlugin::teardown()` would get called (on the main thread), it would
wait for the PDF thread to complete. However, if loading is still going on,
the PDF thread might be blocked on `dataSemaphore.wait()` in
PDFIncrementalLoader::dataProviderGetBytesAtPosition(). The `dataSemaphore`
is supposed to get signaled on a task dispatched to the main thread but this
task won't run if the main thread is blocked on waiting for the thread to
exit.

To address the issue, PDFIncrementalLoader::clear() now signals the
pending dataSemaphores before waiting for the thread to exit and sets a
flag indicating we want the thread to exit. This flag is then checked
on the PDF thread to make sure we don't queue additional work / semaphores.

* LayoutTests/compositing/plugins/pdf/pdf-plugin-hang-during-destruction-expected.txt: Added.
* LayoutTests/compositing/plugins/pdf/pdf-plugin-hang-during-destruction.html: Added.
I took the test from Erica Li's earlier PR that got reverted.

* Source/WebKit/WebProcess/Plugins/PDF/PDFIncrementalLoader.h:
(WebKit::PDFIncrementalLoader::SemaphoreWrapper::create):
(WebKit::PDFIncrementalLoader::SemaphoreWrapper::wait):
(WebKit::PDFIncrementalLoader::SemaphoreWrapper::signal):
(WebKit::PDFIncrementalLoader::WTF_GUARDED_BY_LOCK):
* Source/WebKit/WebProcess/Plugins/PDF/PDFIncrementalLoader.mm:
(WebKit::PDFIncrementalLoader::clear):
(WebKit::PDFIncrementalLoader::dataProviderGetBytesAtPosition):
(WebKit::PDFIncrementalLoader::dataProviderGetByteRanges):
(WebKit::PDFIncrementalLoader::threadEntry):

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



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


More information about the webkit-changes mailing list