WebKit Bugzilla
Attachment 341541 Details for
Bug 185330
: [iOS] Add assert to catch improper use of WebCore::Timer in UI Process
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch v2
bug-185330-20180529170921.patch (text/plain), 9.88 KB, created by
David Kilzer (:ddkilzer)
on 2018-05-29 17:09:21 PDT
(
hide
)
Description:
Patch v2
Filename:
MIME Type:
Creator:
David Kilzer (:ddkilzer)
Created:
2018-05-29 17:09:21 PDT
Size:
9.88 KB
patch
obsolete
>Subversion Revision: 232275 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 06db959ebf4119790b56c71b9b5e283837eaf8f0..0c6a4a9ca78b8d6d04b563fc72277a70bed23844 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,37 @@ >+2018-05-29 David Kilzer <ddkilzer@apple.com> >+ >+ [iOS] Add assert to catch improper use of WebCore::Timer in UI Process >+ <https://webkit.org/b/185330> >+ <rdar://problem/32816079> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * platform/RuntimeApplicationChecks.h: >+ (WebCore::setIsInNetworkProcess): Declare new function. >+ (WebCore::isInNetworkProcess): Ditto. >+ (WebCore::setIsInStorageProcess): Ditto. >+ (WebCore::isInStorageProcess): Ditto. >+ (WebCore::setIsInWebProcess): Ditto. >+ * platform/Timer.cpp: >+ (WebCore::TimerBase::TimerBase): Add assert and os_log_fault. >+ This catches the unwanted behavior using >+ isAllowedToUseWebCoreTimer(). >+ (WebCore::TimerBase::isAllowedToUseWebCoreTimer): Add. >+ * platform/Timer.h: >+ (WebCore::TimerBase::isAllowedToUseWebCoreTimer): Add >+ declaration. >+ * platform/cocoa/RuntimeApplicationChecksCocoa.mm: >+ (s_isInNetworkProcess): Add. Global to track Network Process state. >+ (s_isInStorageProcess): Add. Global to track Storage Process state. >+ (s_isInWebProcess): Add. Global to track Web Process state. >+ (WebCore::setIsInNetworkProcess): Add. Sets global to true. >+ (WebCore::isInNetworkProcess): Add. Retun value of global. >+ (WebCore::setIsInStorageProcess): Add. Sets global to true. >+ (WebCore::isInStorageProcess): Add. Retun value of global. >+ (WebCore::setIsInWebProcess): Add. Sets global to true. >+ (WebCore::isInWebProcess): Replace bundle checks by returning >+ value of global. >+ > 2018-05-29 Ryosuke Niwa <rniwa@webkit.org> > > iOS WK1: Occasional crash in sanitizedMarkupForFragmentInDocument >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 68f2a5607cd72c2285597aadef8fb9bc8cbcb3cb..64188cc3468c0f76d38cd1cd1b897aac8d5bee04 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,21 @@ >+2018-05-29 David Kilzer <ddkilzer@apple.com> >+ >+ [iOS] Add assert to catch improper use of WebCore::Timer in UI Process >+ <https://webkit.org/b/185330> >+ <rdar://problem/32816079> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * NetworkProcess/NetworkProcess.cpp: >+ (WebKit::NetworkProcess::NetworkProcess): Call >+ WebCore::setIsInNetworkProcess() to set the global. >+ * StorageProcess/StorageProcess.cpp: >+ (WebKit::StorageProcess::StorageProcess): Call >+ WebCore::setIsInStorageProcess() to set the global. >+ * WebProcess/WebProcess.cpp: >+ (WebKit::WebProcess::WebProcess): Call >+ WebCore::setIsInWebProcess() to set the global. >+ > 2018-05-29 Chris Dumez <cdumez@apple.com> > > Store 0-lifetime stylesheets / scripts into the disk cache for faster history navigations >diff --git a/Source/WebCore/platform/RuntimeApplicationChecks.h b/Source/WebCore/platform/RuntimeApplicationChecks.h >index 94e28f8592e1548338f28116009edc5444e9ec94..2649ea3a470713978c2bb860789ec8744b42247f 100644 >--- a/Source/WebCore/platform/RuntimeApplicationChecks.h >+++ b/Source/WebCore/platform/RuntimeApplicationChecks.h >@@ -40,6 +40,11 @@ inline bool isInWebProcess() { return true; } > > #if PLATFORM(COCOA) > >+WEBCORE_EXPORT void setIsInNetworkProcess(); >+bool isInNetworkProcess(); >+WEBCORE_EXPORT void setIsInStorageProcess(); >+bool isInStorageProcess(); >+WEBCORE_EXPORT void setIsInWebProcess(); > bool isInWebProcess(); > > WEBCORE_EXPORT void setApplicationBundleIdentifier(const String&); >diff --git a/Source/WebCore/platform/Timer.cpp b/Source/WebCore/platform/Timer.cpp >index 43a5920bfc1ffd079029456fb7cc6efe272c6ccf..6e522ad2213d8a8066a0aee755ccfef159cb2fd0 100644 >--- a/Source/WebCore/platform/Timer.cpp >+++ b/Source/WebCore/platform/Timer.cpp >@@ -27,15 +27,22 @@ > #include "config.h" > #include "Timer.h" > >+#include "Logging.h" >+#include "RuntimeApplicationChecks.h" > #include "SharedTimer.h" > #include "ThreadGlobalData.h" > #include "ThreadTimers.h" > #include <limits.h> > #include <limits> > #include <math.h> >+#include <wtf/Compiler.h> > #include <wtf/MainThread.h> > #include <wtf/Vector.h> > >+#if USE(WEB_THREAD) >+#include "WebCoreThread.h" >+#endif >+ > namespace WebCore { > > class TimerHeapReference; >@@ -186,6 +193,14 @@ inline bool TimerHeapLessThanFunction::operator()(const TimerBase* a, const Time > > TimerBase::TimerBase() > { >+#if PLATFORM(IOS) >+ if (UNLIKELY(!isAllowedToUseWebCoreTimer())) { >+#define WEBCORE_TIMERBASE_ASSERTION_MESSAGE "WebCore::Timer should not be used in UI Process." >+ ASSERT_WITH_MESSAGE(false, WEBCORE_TIMERBASE_ASSERTION_MESSAGE); >+ RELEASE_LOG_FAULT(Threading, WEBCORE_TIMERBASE_ASSERTION_MESSAGE); >+#undef WEBCORE_TIMERBASE_ASSERTION_MESSAGE >+ } >+#endif > } > > TimerBase::~TimerBase() >@@ -242,6 +257,23 @@ inline void TimerBase::checkConsistency() const > checkHeapIndex(); > } > >+bool TimerBase::isAllowedToUseWebCoreTimer() >+{ >+#if PLATFORM(IOS) >+ if (isInWebProcess() || isInNetworkProcess() || isInStorageProcess()) >+ return true; >+ >+#if USE(WEB_THREAD) >+ if (WebThreadIsEnabled() && (WebThreadIsCurrent() || WebThreadIsLocked())) >+ return true; >+#endif >+ >+ return false; >+#else >+ return true; >+#endif >+} >+ > void TimerBase::heapDecreaseKey() > { > ASSERT(static_cast<bool>(m_nextFireTime)); >diff --git a/Source/WebCore/platform/Timer.h b/Source/WebCore/platform/Timer.h >index 5e757d40555caf56cb0c0834ef3319013f29f24f..58c153d30af402b6403e2413cbf404bb59f3e1a1 100644 >--- a/Source/WebCore/platform/Timer.h >+++ b/Source/WebCore/platform/Timer.h >@@ -78,6 +78,8 @@ private: > void checkConsistency() const; > void checkHeapIndex() const; > >+ static bool isAllowedToUseWebCoreTimer(); >+ > void setNextFireTime(MonotonicTime); > > bool inHeap() const { return m_heapIndex != -1; } >diff --git a/Source/WebCore/platform/cocoa/RuntimeApplicationChecksCocoa.mm b/Source/WebCore/platform/cocoa/RuntimeApplicationChecksCocoa.mm >index 2f379a3da2d317e66a534cd55e0fa67179c2bdac..8dff2e9e2487240ece611c021e293f710aced833 100644 >--- a/Source/WebCore/platform/cocoa/RuntimeApplicationChecksCocoa.mm >+++ b/Source/WebCore/platform/cocoa/RuntimeApplicationChecksCocoa.mm >@@ -38,6 +38,9 @@ namespace WebCore { > #if !ASSERT_MSG_DISABLED > static bool applicationBundleIdentifierOverrideWasQueried; > #endif >+static bool s_isInNetworkProcess; >+static bool s_isInStorageProcess; >+static bool s_isInWebProcess; > > // The application bundle identifier gets set to the UIProcess bundle identifier by the WebProcess and > // the Networking upon initialization. It is unset otherwise. >@@ -65,12 +68,34 @@ void setApplicationBundleIdentifier(const String& bundleIdentifier) > applicationBundleIdentifierOverride() = bundleIdentifier; > } > >+void setIsInNetworkProcess() >+{ >+ s_isInNetworkProcess = true; >+} >+ >+bool isInNetworkProcess() >+{ >+ return s_isInNetworkProcess; >+} >+ >+void setIsInStorageProcess() >+{ >+ s_isInStorageProcess = true; >+} >+ >+bool isInStorageProcess() >+{ >+ return s_isInStorageProcess; >+} >+ >+void setIsInWebProcess() >+{ >+ s_isInWebProcess = true; >+} >+ > bool isInWebProcess() > { >- static bool mainBundleIsWebProcess = [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.WebKit.WebContent.Development"] >- || [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.WebKit.WebContent"] >- || [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.WebProcess"]; >- return mainBundleIsWebProcess; >+ return s_isInWebProcess; > } > > static bool applicationBundleIsEqualTo(const String& bundleIdentifierString) >diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.cpp b/Source/WebKit/NetworkProcess/NetworkProcess.cpp >index 9b313c9ccc39705a805719f402d2890644d7efab..bb1f4509b9c28ea4687f09f4de9aeac26052b8f3 100644 >--- a/Source/WebKit/NetworkProcess/NetworkProcess.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkProcess.cpp >@@ -128,6 +128,10 @@ NetworkProcess::NetworkProcess() > for (auto& webProcessConnection : webProcessConnections) > webProcessConnection->setOnLineState(isOnLine); > }); >+ >+#if PLATFORM(COCOA) >+ WebCore::setIsInNetworkProcess(); >+#endif > } > > NetworkProcess::~NetworkProcess() >diff --git a/Source/WebKit/StorageProcess/StorageProcess.cpp b/Source/WebKit/StorageProcess/StorageProcess.cpp >index 421ce76c65b3c1b7168aa2636b628a05db6ba422..0496ee311581e8860e49b30a1b4e8120ab868202 100644 >--- a/Source/WebKit/StorageProcess/StorageProcess.cpp >+++ b/Source/WebKit/StorageProcess/StorageProcess.cpp >@@ -40,6 +40,7 @@ > #include <WebCore/FileSystem.h> > #include <WebCore/IDBKeyData.h> > #include <WebCore/NotImplemented.h> >+#include <WebCore/RuntimeApplicationChecks.h> > #include <WebCore/SWServerWorker.h> > #include <WebCore/SecurityOrigin.h> > #include <WebCore/ServiceWorkerClientIdentifier.h> >@@ -72,6 +73,10 @@ StorageProcess::StorageProcess() > // Make sure the UTF8Encoding encoding and the text encoding maps have been built on the main thread before a background thread needs it. > // FIXME: https://bugs.webkit.org/show_bug.cgi?id=135365 - Need a more explicit way of doing this besides accessing the UTF8Encoding. > UTF8Encoding(); >+ >+#if PLATFORM(COCOA) >+ WebCore::setIsInStorageProcess(); >+#endif > } > > StorageProcess::~StorageProcess() >diff --git a/Source/WebKit/WebProcess/WebProcess.cpp b/Source/WebKit/WebProcess/WebProcess.cpp >index 3723b6689a72093952baeff3326896f61c9bc54f..0661d62b945f5d1953b38961a0f4d17b758c364d 100644 >--- a/Source/WebKit/WebProcess/WebProcess.cpp >+++ b/Source/WebKit/WebProcess/WebProcess.cpp >@@ -209,6 +209,10 @@ WebProcess::WebProcess() > }); > > Gigacage::disableDisablingPrimitiveGigacageIfShouldBeEnabled(); >+ >+#if PLATFORM(COCOA) >+ WebCore::setIsInWebProcess(); >+#endif > } > > WebProcess::~WebProcess()
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185330
:
340571
|
340637
|
341175
|
341181
|
341183
|
341541
|
344076
|
344083
|
344217
|
344224