Changeset 211569 in webkit
- Timestamp:
- Feb 2, 2017 10:31:54 AM (7 years ago)
- Location:
- trunk/Source
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r211564 r211569 1 2017-02-02 Chris Dumez <cdumez@apple.com> 2 3 [Crash] com.apple.WebKit.WebContent at WebKit: WebKit::WebPage::fromCorePage() 4 https://bugs.webkit.org/show_bug.cgi?id=167738 5 <rdar://problem/30229990> 6 7 Reviewed by Andreas Kling. 8 9 Upon destruction of a Page, we destroy the BackForwardClient, which is supposed 10 to keep track of HistoryItems associated to this particular page and remove them 11 from the PageCache. Given the crash trace, the issue seems to be that some 12 HistoryItems associated with the Page sometimes linger in the PageCache *after* 13 the Page has been destroyed, which leads to crashes later on when pruning the 14 PageCache. 15 16 In order to make the process more robust, this patch refactors the code so that 17 the Page is now in charge of removing all its associated HistoryItems from the 18 PageCache instead of relying on the BackForwardClient. Also, instead of having 19 the Page keep track of which HistoryItems are associated with it (which is 20 error prone), we now scan all PageCache entries instead to find which ones are 21 associated with the Page. While this is in theory slower, this is much safer 22 and in practice not an issue because the PageCache usually has 3-5 entries. 23 24 No new tests, could not reproduce. 25 26 * history/CachedPage.cpp: 27 (WebCore::CachedPage::CachedPage): 28 * history/CachedPage.h: 29 (WebCore::CachedPage::page): 30 * history/PageCache.cpp: 31 (WebCore::PageCache::removeAllItemsForPage): 32 * history/PageCache.h: 33 * page/Page.cpp: 34 (WebCore::Page::~Page): 35 1 36 2017-02-02 Antti Koivisto <antti@apple.com> 2 37 -
trunk/Source/WebCore/history/CachedPage.cpp
r207620 r211569 51 51 52 52 CachedPage::CachedPage(Page& page) 53 : m_expirationTime(monotonicallyIncreasingTime() + page.settings().backForwardCacheExpirationInterval()) 53 : m_page(page) 54 , m_expirationTime(monotonicallyIncreasingTime() + page.settings().backForwardCacheExpirationInterval()) 54 55 , m_cachedMainFrame(std::make_unique<CachedFrame>(page.mainFrame())) 55 56 { -
trunk/Source/WebCore/history/CachedPage.h
r208646 r211569 43 43 void clear(); 44 44 45 Page& page() const { return m_page; } 45 46 Document* document() const { return m_cachedMainFrame->document(); } 46 47 DocumentLoader* documentLoader() const { return m_cachedMainFrame->documentLoader(); } … … 59 60 60 61 private: 62 Page& m_page; 61 63 double m_expirationTime; 62 64 std::unique_ptr<CachedFrame> m_cachedMainFrame; -
trunk/Source/WebCore/history/PageCache.cpp
r211291 r211569 467 467 } 468 468 469 void PageCache::removeAllItemsForPage(Page& page) 470 { 471 for (auto it = m_items.begin(); it != m_items.end();) { 472 // Increment iterator first so it stays invalid after the removal. 473 auto current = it; 474 ++it; 475 if (&(*current)->m_cachedPage->page() == &page) { 476 (*current)->m_cachedPage = nullptr; 477 m_items.remove(current); 478 } 479 } 480 } 481 469 482 CachedPage* PageCache::get(HistoryItem& item, Page* page) 470 483 { -
trunk/Source/WebCore/history/PageCache.h
r209865 r211569 58 58 std::unique_ptr<CachedPage> take(HistoryItem&, Page*); 59 59 60 void removeAllItemsForPage(Page&); 61 60 62 unsigned pageCount() const { return m_items.size(); } 61 63 WEBCORE_EXPORT unsigned frameCount() const; -
trunk/Source/WebCore/page/Page.cpp
r211254 r211569 326 326 327 327 backForward().close(); 328 PageCache::singleton().removeAllItemsForPage(*this); 328 329 329 330 #ifndef NDEBUG -
trunk/Source/WebKit/mac/ChangeLog
r211551 r211569 1 2017-02-02 Chris Dumez <cdumez@apple.com> 2 3 [Crash] com.apple.WebKit.WebContent at WebKit: WebKit::WebPage::fromCorePage() 4 https://bugs.webkit.org/show_bug.cgi?id=167738 5 <rdar://problem/30229990> 6 7 Reviewed by Andreas Kling. 8 9 The BackForwardClient no longer needs to worry about removing HistoryItems 10 from the PageCache now that WebCore takes care of it. 11 12 * History/BackForwardList.mm: 13 (BackForwardList::close): 14 1 15 2017-02-02 Yongjun Zhang <yongjun_zhang@apple.com> 2 16 -
trunk/Source/WebKit/mac/History/BackForwardList.mm
r207419 r211569 226 226 void BackForwardList::close() 227 227 { 228 for (auto& item : m_entries)229 PageCache::singleton().remove(item);230 228 m_entries.clear(); 231 229 m_entryHash.clear(); -
trunk/Source/WebKit/win/BackForwardList.cpp
r210697 r211569 226 226 void BackForwardList::close() 227 227 { 228 for (auto& item : m_entries)229 PageCache::singleton().remove(item);230 228 m_entries.clear(); 231 229 m_entryHash.clear(); -
trunk/Source/WebKit/win/ChangeLog
r211341 r211569 1 2017-02-02 Chris Dumez <cdumez@apple.com> 2 3 [Crash] com.apple.WebKit.WebContent at WebKit: WebKit::WebPage::fromCorePage() 4 https://bugs.webkit.org/show_bug.cgi?id=167738 5 <rdar://problem/30229990> 6 7 Reviewed by Andreas Kling. 8 9 The BackForwardClient no longer needs to worry about removing HistoryItems 10 from the PageCache now that WebCore takes care of it. 11 12 * BackForwardList.cpp: 13 (BackForwardList::close): 14 1 15 2017-01-28 Yoav Weiss <yoav@yoav.ws> 2 16 -
trunk/Source/WebKit2/ChangeLog
r211568 r211569 1 2017-02-02 Chris Dumez <cdumez@apple.com> 2 3 [Crash] com.apple.WebKit.WebContent at WebKit: WebKit::WebPage::fromCorePage() 4 https://bugs.webkit.org/show_bug.cgi?id=167738 5 <rdar://problem/30229990> 6 7 Reviewed by Andreas Kling. 8 9 The BackForwardClient no longer needs to worry about removing HistoryItems 10 from the PageCache now that WebCore takes care of it. 11 12 * WebProcess/WebPage/WebBackForwardListProxy.cpp: 13 (WebKit::WebBackForwardListProxy::addItemFromUIProcess): 14 (WebKit::WebBackForwardListProxy::addItem): 15 (WebKit::WebBackForwardListProxy::close): 16 * WebProcess/WebPage/WebBackForwardListProxy.h: 17 1 18 2017-02-02 Anders Carlsson <andersca@apple.com> 2 19 -
trunk/Source/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.cpp
r210666 r211569 101 101 ASSERT(!idToHistoryItemMap().contains(itemID)); 102 102 103 m_associatedItemIDs.add(itemID);104 105 103 historyItemToIDMap().set<ItemAndPageID>(item.ptr(), { .itemID = itemID, .pageID = pageID }); 106 104 idToHistoryItemMap().set(itemID, item.ptr()); … … 155 153 ASSERT(!idToHistoryItemMap().contains(itemID)); 156 154 157 m_associatedItemIDs.add(itemID);158 159 155 historyItemToIDMap().set<ItemAndPageID>(item.ptr(), { .itemID = itemID, .pageID = m_page->pageID() }); 160 156 idToHistoryItemMap().set(itemID, item.ptr()); … … 215 211 void WebBackForwardListProxy::close() 216 212 { 217 for (auto& itemID : m_associatedItemIDs) {218 if (HistoryItem* item = itemForID(itemID))219 WebCore::PageCache::singleton().remove(*item);220 }221 222 m_associatedItemIDs.clear();223 213 m_page = nullptr; 224 214 } -
trunk/Source/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.h
r210666 r211569 61 61 62 62 WebPage* m_page; 63 HashSet<uint64_t> m_associatedItemIDs;64 63 }; 65 64
Note: See TracChangeset
for help on using the changeset viewer.