Bug 224530

Summary: Wait until thread exits in CrossThreadTaskHandler::kill()
Product: WebKit Reporter: Sihui Liu <sihui_liu>
Component: New BugsAssignee: Sihui Liu <sihui_liu>
Status: NEW    
Severity: Normal CC: achristensen, beidson, benjamin, cdumez, cmarcelo, ews-watchlist, ggaren, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch ews-feeder: commit-queue-

Sihui Liu
Reported 2021-04-13 22:33:41 PDT
...
Attachments
Patch (4.92 KB, patch)
2021-04-13 23:07 PDT, Sihui Liu
no flags
Patch (6.34 KB, patch)
2021-04-14 10:18 PDT, Sihui Liu
no flags
Patch (6.69 KB, patch)
2021-04-14 11:13 PDT, Sihui Liu
ews-feeder: commit-queue-
Sihui Liu
Comment 1 2021-04-13 23:07:39 PDT
Chris Dumez
Comment 2 2021-04-13 23:17:05 PDT
Comment on attachment 425954 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=425954&action=review > Source/WTF/ChangeLog:7 > + Please explain WHY you are making this change.
Sihui Liu
Comment 3 2021-04-14 10:18:29 PDT
Sihui Liu
Comment 4 2021-04-14 10:18:52 PDT
(In reply to Chris Dumez from comment #2) > Comment on attachment 425954 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=425954&action=review > > > Source/WTF/ChangeLog:7 > > + > > Please explain WHY you are making this change. Added.
Chris Dumez
Comment 5 2021-04-14 10:30:09 PDT
Comment on attachment 425997 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=425997&action=review > Source/WebKit/NetworkProcess/IndexedDB/WebIDBServer.cpp:425 > + CrossThreadTaskHandler::kill(); I have several concerns about this patch: 1. The verb "kill", to me, is not really associated with "wait for remaining tasks to be processed and wait for thread to exit" 2. The new code hangs the NetworkProcess's main thread on a background thread that is used for database activity (such activity likely includes going to disk). I don't think it is ever OK to hang the main thread on such operations. I am all for making the code safe but making the code safe by hanging the main thread does not seem like a good trade-off.
Sihui Liu
Comment 6 2021-04-14 11:00:08 PDT
(In reply to Chris Dumez from comment #5) > Comment on attachment 425997 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=425997&action=review > > > Source/WebKit/NetworkProcess/IndexedDB/WebIDBServer.cpp:425 > > + CrossThreadTaskHandler::kill(); > > I have several concerns about this patch: > 1. The verb "kill", to me, is not really associated with "wait for remaining > tasks to be processed and wait for thread to exit" I think so too; can rename it to something like waitUntilFinished(). > 2. The new code hangs the NetworkProcess's main thread on a background > thread that is used for database activity (such activity likely includes > going to disk). I don't think it is ever OK to hang the main thread on such > operations. > ah, I don't think this is a big concern for database thread because WebIDBServer (the only user of CrossThreadTaskHandler for now) is removed in 2 cases: 1. it's idle, no pending tasks or IDB connection from web process. This means the kill operation should be very quick. 2. network process is about to be destroyed (NetworkProcess::didClose). I guess network process does not matter so much at this point. > I am all for making the code safe but making the code safe by hanging the > main thread does not seem like a good trade-off.
Sihui Liu
Comment 7 2021-04-14 11:13:15 PDT
Chris Dumez
Comment 8 2021-04-14 14:30:08 PDT
Comment on attachment 426017 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=426017&action=review > Source/WTF/ChangeLog:9 > + 1. CrossThreadQueue<DataType>::waitForMessage() expects a new task before checking m_killed CrossThreadQueue<DataType>::waitForMessage() should probably be fixed so that it checked m_killed when woken up: - while (found == m_queue.end()) { + while (!m_killed && found == m_queue.end()) {
Radar WebKit Bug Importer
Comment 9 2021-04-20 22:34:14 PDT
Note You need to log in before you can comment on or make changes to this bug.