-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
4 changed files
with
96 additions
and
13 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
LayoutTests/compositing/plugins/pdf/pdf-plugin-hang-during-destruction-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This test passes if it does not timeout. | ||
|
||
|
17 changes: 17 additions & 0 deletions
17
LayoutTests/compositing/plugins/pdf/pdf-plugin-hang-during-destruction.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<script> | ||
if (window.testRunner) | ||
testRunner.dumpAsText(); | ||
onload = async () => { | ||
let iframe0 = document.createElement('iframe'); | ||
iframe0.src = 'data:application/pdf,x'; | ||
document.body.append(iframe0); | ||
|
||
await caches.has('a'); | ||
await caches.has('a'); | ||
|
||
$vm.print('before'); | ||
iframe0.remove(); | ||
$vm.print('after'); | ||
}; | ||
</script> | ||
<p>This test passes if it does not timeout.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters