- Revision
- 203371
- Author
- [email protected]
- Date
- 2016-07-18 13:41:18 -0700 (Mon, 18 Jul 2016)
Log Message
Mail contents are temporarily obscured by black rectangles when returning from suspend and in app switcher
https://bugs.webkit.org/show_bug.cgi?id=159894
<rdar://problem/26973202>
Reviewed by Simon Fraser.
* UIProcess/ApplicationStateTracker.h:
* UIProcess/ApplicationStateTracker.mm:
(WebKit::ApplicationStateTracker::ApplicationStateTracker):
(WebKit::ApplicationStateTracker::~ApplicationStateTracker):
(WebKit::ApplicationStateTracker::applicationDidCreateWindowContext):
* UIProcess/ios/WKContentView.mm:
(-[WKContentView didMoveToWindow]):
(-[WKContentView _applicationDidCreateWindowContext]):
(-[WKContentView _applicationWillEnterForeground]): Deleted.
* UIProcess/ios/WKPDFView.mm:
(-[WKPDFView didMoveToWindow]):
(-[WKPDFView _applicationDidCreateWindowContext]):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::applicationDidFinishSnapshottingAfterEnteringBackground):
Hide content at window context creation time, instead of when the application
becomes foregrounded. Otherwise, background snapshots (which create/destroy
window contexts, but do not bring the app into the foreground) can have
parented layers that have volatile surfaces in them. In the normal case,
we will subsequently get foregrounded and re-build the layer tree; in the
background snapshot case, we will just have an empty layer tree.
In the future, we should consider making ApplicationStateTracker use
window context creation/destruction to drive web process lifetime, so
that we can actually paint correctly for background snapshots.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (203370 => 203371)
--- trunk/Source/WebKit2/ChangeLog 2016-07-18 20:31:20 UTC (rev 203370)
+++ trunk/Source/WebKit2/ChangeLog 2016-07-18 20:41:18 UTC (rev 203371)
@@ -1,3 +1,36 @@
+2016-07-18 Tim Horton <[email protected]>
+
+ Mail contents are temporarily obscured by black rectangles when returning from suspend and in app switcher
+ https://bugs.webkit.org/show_bug.cgi?id=159894
+ <rdar://problem/26973202>
+
+ Reviewed by Simon Fraser.
+
+ * UIProcess/ApplicationStateTracker.h:
+ * UIProcess/ApplicationStateTracker.mm:
+ (WebKit::ApplicationStateTracker::ApplicationStateTracker):
+ (WebKit::ApplicationStateTracker::~ApplicationStateTracker):
+ (WebKit::ApplicationStateTracker::applicationDidCreateWindowContext):
+ * UIProcess/ios/WKContentView.mm:
+ (-[WKContentView didMoveToWindow]):
+ (-[WKContentView _applicationDidCreateWindowContext]):
+ (-[WKContentView _applicationWillEnterForeground]): Deleted.
+ * UIProcess/ios/WKPDFView.mm:
+ (-[WKPDFView didMoveToWindow]):
+ (-[WKPDFView _applicationDidCreateWindowContext]):
+ * UIProcess/ios/WebPageProxyIOS.mm:
+ (WebKit::WebPageProxy::applicationDidFinishSnapshottingAfterEnteringBackground):
+ Hide content at window context creation time, instead of when the application
+ becomes foregrounded. Otherwise, background snapshots (which create/destroy
+ window contexts, but do not bring the app into the foreground) can have
+ parented layers that have volatile surfaces in them. In the normal case,
+ we will subsequently get foregrounded and re-build the layer tree; in the
+ background snapshot case, we will just have an empty layer tree.
+
+ In the future, we should consider making ApplicationStateTracker use
+ window context creation/destruction to drive web process lifetime, so
+ that we can actually paint correctly for background snapshots.
+
2016-07-18 Carlos Garcia Campos <[email protected]>
Unreviewed. Update OptionsGTK.cmake and NEWS for 2.13.3 release.
Modified: trunk/Source/WebKit2/UIProcess/ApplicationStateTracker.h (203370 => 203371)
--- trunk/Source/WebKit2/UIProcess/ApplicationStateTracker.h 2016-07-18 20:31:20 UTC (rev 203370)
+++ trunk/Source/WebKit2/UIProcess/ApplicationStateTracker.h 2016-07-18 20:41:18 UTC (rev 203371)
@@ -39,7 +39,7 @@
class ApplicationStateTracker {
public:
- ApplicationStateTracker(UIView *, SEL didEnterBackgroundSelector, SEL didFinishSnapshottingAfterEnteringBackgroundSelector, SEL willEnterForegroundSelector);
+ ApplicationStateTracker(UIView *, SEL didEnterBackgroundSelector, SEL didCreateWindowContextSelector, SEL didFinishSnapshottingAfterEnteringBackgroundSelector, SEL willEnterForegroundSelector);
~ApplicationStateTracker();
bool isInBackground() const { return m_isInBackground; }
@@ -46,11 +46,13 @@
private:
void applicationDidEnterBackground();
+ void applicationDidCreateWindowContext();
void applicationDidFinishSnapshottingAfterEnteringBackground();
void applicationWillEnterForeground();
WeakObjCPtr<UIView> m_view;
SEL m_didEnterBackgroundSelector;
+ SEL m_didCreateWindowContextSelector;
SEL m_didFinishSnapshottingAfterEnteringBackgroundSelector;
SEL m_willEnterForegroundSelector;
@@ -61,6 +63,7 @@
RetainPtr<BKSApplicationStateMonitor> m_applicationStateMonitor;
id m_didEnterBackgroundObserver;
+ id m_didCreateWindowContextObserver;
id m_didFinishSnapshottingAfterEnteringBackgroundObserver;
id m_willEnterForegroundObserver;
};
Modified: trunk/Source/WebKit2/UIProcess/ApplicationStateTracker.mm (203370 => 203371)
--- trunk/Source/WebKit2/UIProcess/ApplicationStateTracker.mm 2016-07-18 20:31:20 UTC (rev 203370)
+++ trunk/Source/WebKit2/UIProcess/ApplicationStateTracker.mm 2016-07-18 20:41:18 UTC (rev 203371)
@@ -73,18 +73,21 @@
}
}
-ApplicationStateTracker::ApplicationStateTracker(UIView *view, SEL didEnterBackgroundSelector, SEL didFinishSnapshottingAfterEnteringBackgroundSelector, SEL willEnterForegroundSelector)
+ApplicationStateTracker::ApplicationStateTracker(UIView *view, SEL didEnterBackgroundSelector, SEL didCreateWindowContextSelector, SEL didFinishSnapshottingAfterEnteringBackgroundSelector, SEL willEnterForegroundSelector)
: m_view(view)
, m_didEnterBackgroundSelector(didEnterBackgroundSelector)
+ , m_didCreateWindowContextSelector(didCreateWindowContextSelector)
, m_didFinishSnapshottingAfterEnteringBackgroundSelector(didFinishSnapshottingAfterEnteringBackgroundSelector)
, m_willEnterForegroundSelector(willEnterForegroundSelector)
, m_isInBackground(true)
, m_weakPtrFactory(this)
, m_didEnterBackgroundObserver(nullptr)
+ , m_didCreateWindowContextObserver(nullptr)
, m_didFinishSnapshottingAfterEnteringBackgroundObserver(nullptr)
, m_willEnterForegroundObserver(nullptr)
{
ASSERT([m_view.get() respondsToSelector:m_didEnterBackgroundSelector]);
+ ASSERT([m_view.get() respondsToSelector:m_didCreateWindowContextSelector]);
ASSERT([m_view.get() respondsToSelector:m_didFinishSnapshottingAfterEnteringBackgroundSelector]);
ASSERT([m_view.get() respondsToSelector:m_willEnterForegroundSelector]);
@@ -93,6 +96,13 @@
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
auto weakThis = m_weakPtrFactory.createWeakPtr();
+ m_didCreateWindowContextObserver = [notificationCenter addObserverForName:@"_UIWindowDidCreateWindowContextNotification" object:window queue:nil usingBlock:[weakThis](NSNotification *) {
+ auto applicationStateTracker = weakThis.get();
+ if (!applicationStateTracker)
+ return;
+ applicationStateTracker->applicationDidCreateWindowContext();
+ }];
+
m_didFinishSnapshottingAfterEnteringBackgroundObserver = [notificationCenter addObserverForName:@"_UIWindowWillDestroyWindowContextNotification" object:window queue:nil usingBlock:[weakThis](NSNotification *) {
auto applicationStateTracker = weakThis.get();
if (!applicationStateTracker)
@@ -183,6 +193,7 @@
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter removeObserver:m_didEnterBackgroundObserver];
+ [notificationCenter removeObserver:m_didCreateWindowContextObserver];
[notificationCenter removeObserver:m_didFinishSnapshottingAfterEnteringBackgroundObserver];
[notificationCenter removeObserver:m_willEnterForegroundObserver];
}
@@ -195,6 +206,12 @@
wtfObjcMsgSend<void>(view.get(), m_didEnterBackgroundSelector);
}
+void ApplicationStateTracker::applicationDidCreateWindowContext()
+{
+ if (auto view = m_view.get())
+ wtfObjcMsgSend<void>(view.get(), m_didCreateWindowContextSelector);
+}
+
void ApplicationStateTracker::applicationDidFinishSnapshottingAfterEnteringBackground()
{
if (auto view = m_view.get())
Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm (203370 => 203371)
--- trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm 2016-07-18 20:31:20 UTC (rev 203370)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm 2016-07-18 20:41:18 UTC (rev 203371)
@@ -284,7 +284,7 @@
return;
ASSERT(!_applicationStateTracker);
- _applicationStateTracker = std::make_unique<ApplicationStateTracker>(self, @selector(_applicationDidEnterBackground), @selector(_applicationDidFinishSnapshottingAfterEnteringBackground), @selector(_applicationWillEnterForeground));
+ _applicationStateTracker = std::make_unique<ApplicationStateTracker>(self, @selector(_applicationDidEnterBackground), @selector(_applicationDidCreateWindowContext), @selector(_applicationDidFinishSnapshottingAfterEnteringBackground), @selector(_applicationWillEnterForeground));
}
- (WKBrowsingContextController *)browsingContextController
@@ -601,6 +601,12 @@
_page->viewStateDidChange(ViewState::AllFlags & ~ViewState::IsInWindow);
}
+- (void)_applicationDidCreateWindowContext
+{
+ if (auto drawingArea = _page->drawingArea())
+ drawingArea->hideContentUntilAnyUpdate();
+}
+
- (void)_applicationDidFinishSnapshottingAfterEnteringBackground
{
_page->applicationDidFinishSnapshottingAfterEnteringBackground();
@@ -609,8 +615,6 @@
- (void)_applicationWillEnterForeground
{
_page->applicationWillEnterForeground();
- if (auto drawingArea = _page->drawingArea())
- drawingArea->hideContentUntilAnyUpdate();
_page->viewStateDidChange(ViewState::AllFlags & ~ViewState::IsInWindow, true, WebPageProxy::ViewStateChangeDispatchMode::Immediate);
}
Modified: trunk/Source/WebKit2/UIProcess/ios/WKPDFView.mm (203370 => 203371)
--- trunk/Source/WebKit2/UIProcess/ios/WKPDFView.mm 2016-07-18 20:31:20 UTC (rev 203370)
+++ trunk/Source/WebKit2/UIProcess/ios/WKPDFView.mm 2016-07-18 20:41:18 UTC (rev 203371)
@@ -864,7 +864,7 @@
return;
ASSERT(!_applicationStateTracker);
- _applicationStateTracker = std::make_unique<ApplicationStateTracker>(self, @selector(_applicationDidEnterBackground), @selector(_applicationDidFinishSnapshottingAfterEnteringBackground), @selector(_applicationWillEnterForeground));
+ _applicationStateTracker = std::make_unique<ApplicationStateTracker>(self, @selector(_applicationDidEnterBackground), @selector(_applicationDidCreateWindowContext), @selector(_applicationDidFinishSnapshottingAfterEnteringBackground), @selector(_applicationWillEnterForeground));
}
- (BOOL)isBackground
@@ -881,6 +881,10 @@
_webView->_page->viewStateDidChange(ViewState::AllFlags & ~ViewState::IsInWindow);
}
+- (void)_applicationDidCreateWindowContext
+{
+}
+
- (void)_applicationDidFinishSnapshottingAfterEnteringBackground
{
_webView->_page->applicationDidFinishSnapshottingAfterEnteringBackground();