Changeset 223690 in webkit
- Timestamp:
- Oct 19, 2017 9:10:47 AM (6 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r223678 r223690 1 2017-10-19 Chris Dumez <cdumez@apple.com> 2 3 http/tests/workers/service/basic-register.html is a flaky failure. 4 https://bugs.webkit.org/show_bug.cgi?id=178494 5 <rdar://problem/35065315> 6 7 Reviewed by Youenn Fablet. 8 9 In WebSWServerConnection::resolveJobInClient(), when a service worker is 10 registered, we: 11 1. Add the origin to the WebSWOriginStore 12 2. Send the IPC to the WebProcess to notify it that the registration succeeded. 13 14 The assumption was that step 1 would be synchronous and would therefore send 15 the shared memory handle to the WebProcess (if the SharedMemory was invalidated) 16 *before* step 2. 17 18 The issue is that step 1 was scheduling a zero-timer to schedule the addition. 19 As a result, there was a race and the WebContent process could check the 20 the WebSWOriginTable *after* being notified that a service worker was registered 21 but *before* it received the SharedMemory handle for the WebSWOriginTable. This 22 could lead to false negatives and was causing the layout test to be flaky. 23 24 To address the issue, step 1 is now synchronous. 25 26 * Shared/SharedStringHashStore.cpp: 27 (WebKit::SharedStringHashStore::SharedStringHashStore): 28 (WebKit::SharedStringHashStore::scheduleAddition): 29 (WebKit::SharedStringHashStore::scheduleRemoval): 30 (WebKit::SharedStringHashStore::contains): 31 (WebKit::SharedStringHashStore::flushPendingChanges): 32 (WebKit::SharedStringHashStore::processPendingOperations): 33 * Shared/SharedStringHashStore.h: 34 * StorageProcess/ServiceWorker/WebSWOriginStore.cpp: 35 (WebKit::WebSWOriginStore::add): 36 (WebKit::WebSWOriginStore::addAll): 37 (WebKit::WebSWOriginStore::remove): 38 * StorageProcess/ServiceWorker/WebSWOriginStore.h: 39 * UIProcess/VisitedLinkStore.cpp: 40 (WebKit::VisitedLinkStore::addVisitedLinkHash): 41 (WebKit::VisitedLinkStore::removeVisitedLinkHash): 42 1 43 2017-10-18 Ryosuke Niwa <rniwa@webkit.org> 2 44 -
trunk/Source/WebKit/Shared/SharedStringHashStore.cpp
r222820 r223690 66 66 SharedStringHashStore::SharedStringHashStore(Client& client) 67 67 : m_client(client) 68 , m_pendingOperationsTimer(RunLoop::main(), this, &SharedStringHashStore::p endingOperationsTimerFired)68 , m_pendingOperationsTimer(RunLoop::main(), this, &SharedStringHashStore::processPendingOperations) 69 69 { 70 70 } … … 75 75 } 76 76 77 void SharedStringHashStore:: add(SharedStringHash sharedStringHash)77 void SharedStringHashStore::scheduleAddition(SharedStringHash sharedStringHash) 78 78 { 79 79 m_pendingOperations.append({ Operation::Add, sharedStringHash }); … … 83 83 } 84 84 85 void SharedStringHashStore:: remove(WebCore::SharedStringHash sharedStringHash)85 void SharedStringHashStore::scheduleRemoval(WebCore::SharedStringHash sharedStringHash) 86 86 { 87 87 m_pendingOperations.append({ Operation::Remove, sharedStringHash }); … … 93 93 bool SharedStringHashStore::contains(WebCore::SharedStringHash sharedStringHash) 94 94 { 95 if (m_pendingOperationsTimer.isActive()) { 96 m_pendingOperationsTimer.stop(); 97 pendingOperationsTimerFired(); 98 } 95 flushPendingChanges(); 99 96 return m_table.contains(sharedStringHash); 100 97 } … … 107 104 m_tableSize = 0; 108 105 m_table.clear(); 106 } 107 108 void SharedStringHashStore::flushPendingChanges() 109 { 110 if (!m_pendingOperationsTimer.isActive()) 111 return; 112 113 m_pendingOperationsTimer.stop(); 114 processPendingOperations(); 109 115 } 110 116 … … 159 165 } 160 166 161 void SharedStringHashStore::p endingOperationsTimerFired()167 void SharedStringHashStore::processPendingOperations() 162 168 { 163 169 unsigned currentTableSize = m_tableSize; -
trunk/Source/WebKit/Shared/SharedStringHashStore.h
r223608 r223690 47 47 48 48 bool createSharedMemoryHandle(SharedMemory::Handle&); 49 void add(WebCore::SharedStringHash); 50 void remove(WebCore::SharedStringHash); 49 50 void scheduleAddition(WebCore::SharedStringHash); 51 void scheduleRemoval(WebCore::SharedStringHash); 52 51 53 bool contains(WebCore::SharedStringHash); 52 54 void clear(); … … 54 56 bool isEmpty() const { return !m_keyCount; } 55 57 58 void flushPendingChanges(); 59 56 60 private: 57 61 void resizeTable(unsigned newTableSize); 58 void p endingOperationsTimerFired();62 void processPendingOperations(); 59 63 60 64 struct Operation { -
trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWOriginStore.cpp
r223608 r223690 44 44 void WebSWOriginStore::add(const SecurityOrigin& origin) 45 45 { 46 m_store.add(computeSharedStringHash(origin.toString())); 46 m_store.scheduleAddition(computeSharedStringHash(origin.toString())); 47 m_store.flushPendingChanges(); 48 } 49 50 void WebSWOriginStore::addAll(const Vector<SecurityOrigin>& origins) 51 { 52 for (auto& origin : origins) 53 m_store.scheduleAddition(computeSharedStringHash(origin.toString())); 54 m_store.flushPendingChanges(); 47 55 } 48 56 49 57 void WebSWOriginStore::remove(const SecurityOrigin& origin) 50 58 { 51 m_store.remove(computeSharedStringHash(origin.toString())); 59 m_store.scheduleRemoval(computeSharedStringHash(origin.toString())); 60 m_store.flushPendingChanges(); 52 61 } 53 62 -
trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWOriginStore.h
r223608 r223690 44 44 45 45 void add(const WebCore::SecurityOrigin&); 46 void addAll(const Vector<WebCore::SecurityOrigin>&); 46 47 void remove(const WebCore::SecurityOrigin&); 47 48 void clear(); -
trunk/Source/WebKit/UIProcess/VisitedLinkStore.cpp
r222820 r223690 80 80 void VisitedLinkStore::addVisitedLinkHash(SharedStringHash linkHash) 81 81 { 82 m_linkHashStore. add(linkHash);82 m_linkHashStore.scheduleAddition(linkHash); 83 83 } 84 84 … … 90 90 void VisitedLinkStore::removeVisitedLinkHash(WebCore::SharedStringHash linkHash) 91 91 { 92 m_linkHashStore. remove(linkHash);92 m_linkHashStore.scheduleRemoval(linkHash); 93 93 } 94 94
Note: See TracChangeset
for help on using the changeset viewer.