https://bugs.webkit.org/show_bug.cgi?id=136260
<rdar://problem/
18107826>
Reviewed by Dan Bernstein.
Previously, when a swipe ended up performing a same-document navigation,
we would never get didFinishLoadForMainFrame nor didFirstVisuallyNonEmptyLayoutForMainFrame
nor would we even get didHitRenderTreeSizeThreshold in all cases, so we would never
remove the swipe snapshot. Previous implementations removed the snapshot on
didSameDocumentNavigation for the main frame if the navigation type was Replace or Pop,
so we will match that behavior.
Also, reinstate the watchdog that starts at swipe-end which would have prevented
this bug from forever breaking the view it was associated with.
Also, defend against removing the snapshot before the swipe has finished (before
we have even caused the navigation that we're watching for the effects of).
* UIProcess/API/mac/WKView.mm:
(-[WKView _didSameDocumentNavigationForMainFrame:]):
* UIProcess/API/mac/WKViewInternal.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame):
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::didSameDocumentNavigationForMainFrame):
* UIProcess/mac/PageClientImpl.h:
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::didSameDocumentNavigationForMainFrame):
Plumb main-frame same-document navigation notification from WebPageProxy
to ViewGestureControllerMac via PageClient and WKView.
* UIProcess/mac/ViewGestureController.h:
* UIProcess/mac/ViewGestureControllerMac.mm:
(WebKit::ViewGestureController::ViewGestureController):
(WebKit::ViewGestureController::beginSwipeGesture):
(WebKit::ViewGestureController::endSwipeGesture):
Keep track of whether a swipe is currently occurring. We can't use
activeGestureType for this because the swipe currently remains the "active"
gesture until the snapshot is removed.
Reintroduce the old swipeWatchdogTimer (and rename the shorter timer that starts
when we get a visually non-empty layout) so that we will always remove the
snapshot after 5 seconds, even if we haven't committed the load.
This could lead to flashing back to the old content if we fail to get a single
byte for 5 seconds, but that is a rare case and should eventually get additional
special treatment (dropping the tiles until we do get content, or some such).
(WebKit::ViewGestureController::didHitRenderTreeSizeThreshold):
If a swipe is still in progress, we haven't done our navigation and thus
don't care about render tree size changes.
(WebKit::ViewGestureController::didFirstVisuallyNonEmptyLayoutForMainFrame):
If a swipe is still in progress, we haven't done our navigation and thus
don't care about layouts.
Stop the 5 second overall watchdog if we start the 3 second after-visuallyNonEmptyLayout
watchdog. This means that the snapshot could stay up for a maximum of 8 seconds
for a very, very slow load.
(WebKit::ViewGestureController::didFinishLoadForMainFrame):
If a swipe is still in progress, we haven't done our navigation and thus
don't care about loads that complete.
(WebKit::ViewGestureController::didSameDocumentNavigationForMainFrame):
Remove the swipe snapshot after painting if we do replaceState or popState.
(WebKit::ViewGestureController::removeSwipeSnapshotAfterRepaint):
If a swipe is still in progress, we shouldn't remove the snapshot yet.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@172966
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2014-08-26 Tim Horton <timothy_horton@apple.com>
+
+ REGRESSION (r172771): Amazon product page becomes unresponsive after swiping back to it
+ https://bugs.webkit.org/show_bug.cgi?id=136260
+ <rdar://problem/18107826>
+
+ Reviewed by Dan Bernstein.
+
+ Previously, when a swipe ended up performing a same-document navigation,
+ we would never get didFinishLoadForMainFrame nor didFirstVisuallyNonEmptyLayoutForMainFrame
+ nor would we even get didHitRenderTreeSizeThreshold in all cases, so we would never
+ remove the swipe snapshot. Previous implementations removed the snapshot on
+ didSameDocumentNavigation for the main frame if the navigation type was Replace or Pop,
+ so we will match that behavior.
+
+ Also, reinstate the watchdog that starts at swipe-end which would have prevented
+ this bug from forever breaking the view it was associated with.
+
+ Also, defend against removing the snapshot before the swipe has finished (before
+ we have even caused the navigation that we're watching for the effects of).
+
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView _didSameDocumentNavigationForMainFrame:]):
+ * UIProcess/API/mac/WKViewInternal.h:
+ * UIProcess/PageClient.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::didSameDocumentNavigationForFrame):
+ * UIProcess/ios/PageClientImplIOS.h:
+ * UIProcess/ios/PageClientImplIOS.mm:
+ (WebKit::PageClientImpl::didSameDocumentNavigationForMainFrame):
+ * UIProcess/mac/PageClientImpl.h:
+ * UIProcess/mac/PageClientImpl.mm:
+ (WebKit::PageClientImpl::didSameDocumentNavigationForMainFrame):
+ Plumb main-frame same-document navigation notification from WebPageProxy
+ to ViewGestureControllerMac via PageClient and WKView.
+
+ * UIProcess/mac/ViewGestureController.h:
+ * UIProcess/mac/ViewGestureControllerMac.mm:
+ (WebKit::ViewGestureController::ViewGestureController):
+ (WebKit::ViewGestureController::beginSwipeGesture):
+ (WebKit::ViewGestureController::endSwipeGesture):
+ Keep track of whether a swipe is currently occurring. We can't use
+ activeGestureType for this because the swipe currently remains the "active"
+ gesture until the snapshot is removed.
+
+ Reintroduce the old swipeWatchdogTimer (and rename the shorter timer that starts
+ when we get a visually non-empty layout) so that we will always remove the
+ snapshot after 5 seconds, even if we haven't committed the load.
+ This could lead to flashing back to the old content if we fail to get a single
+ byte for 5 seconds, but that is a rare case and should eventually get additional
+ special treatment (dropping the tiles until we do get content, or some such).
+
+ (WebKit::ViewGestureController::didHitRenderTreeSizeThreshold):
+ If a swipe is still in progress, we haven't done our navigation and thus
+ don't care about render tree size changes.
+
+ (WebKit::ViewGestureController::didFirstVisuallyNonEmptyLayoutForMainFrame):
+ If a swipe is still in progress, we haven't done our navigation and thus
+ don't care about layouts.
+
+ Stop the 5 second overall watchdog if we start the 3 second after-visuallyNonEmptyLayout
+ watchdog. This means that the snapshot could stay up for a maximum of 8 seconds
+ for a very, very slow load.
+
+ (WebKit::ViewGestureController::didFinishLoadForMainFrame):
+ If a swipe is still in progress, we haven't done our navigation and thus
+ don't care about loads that complete.
+
+ (WebKit::ViewGestureController::didSameDocumentNavigationForMainFrame):
+ Remove the swipe snapshot after painting if we do replaceState or popState.
+
+ (WebKit::ViewGestureController::removeSwipeSnapshotAfterRepaint):
+ If a swipe is still in progress, we shouldn't remove the snapshot yet.
+
2014-08-26 Carlos Garcia Campos <cgarcia@igalia.com>
[GTK] Translations are not initialized in the UI process
_data->_gestureController->didFinishLoadForMainFrame();
}
+- (void)_didSameDocumentNavigationForMainFrame:(SameDocumentNavigationType)type
+{
+ if (_data->_gestureController)
+ _data->_gestureController->didSameDocumentNavigationForMainFrame(type);
+}
+
- (void)_removeNavigationGestureSnapshot
{
if (_data->_gestureController)
#import "WKViewPrivate.h"
#import "PluginComplexTextInputState.h"
+#import "SameDocumentNavigationType.h"
#import "WebFindOptions.h"
#import <wtf/Forward.h>
#import <wtf/RetainPtr.h>
- (void)_didFirstVisuallyNonEmptyLayoutForMainFrame;
- (void)_didFinishLoadForMainFrame;
+- (void)_didSameDocumentNavigationForMainFrame:(WebKit::SameDocumentNavigationType)type;
- (void)_removeNavigationGestureSnapshot;
#if WK_API_ENABLED
virtual void didFirstVisuallyNonEmptyLayoutForMainFrame() = 0;
virtual void didFinishLoadForMainFrame() = 0;
+ virtual void didSameDocumentNavigationForMainFrame(SameDocumentNavigationType) = 0;
};
} // namespace WebKit
auto transaction = m_pageLoadState.transaction();
- if (frame->isMainFrame())
+ bool isMainFrame = frame->isMainFrame();
+ if (isMainFrame)
m_pageLoadState.didSameDocumentNavigation(transaction, url);
m_pageLoadState.clearPendingAPIRequestURL(transaction);
frame->didSameDocumentNavigation(url);
m_pageLoadState.commitChanges();
- m_loaderClient->didSameDocumentNavigationForFrame(this, frame, navigationID, static_cast<SameDocumentNavigationType>(opaqueSameDocumentNavigationType), userData.get());
+
+ SameDocumentNavigationType navigationType = static_cast<SameDocumentNavigationType>(opaqueSameDocumentNavigationType);
+ m_loaderClient->didSameDocumentNavigationForFrame(this, frame, navigationID, navigationType, userData.get());
+
+ if (isMainFrame)
+ m_pageClient.didSameDocumentNavigationForMainFrame(navigationType);
}
void WebPageProxy::didReceiveTitleForFrame(uint64_t frameID, const String& title, IPC::MessageDecoder& decoder)
virtual void didFirstVisuallyNonEmptyLayoutForMainFrame() override;
virtual void didFinishLoadForMainFrame() override;
+ virtual void didSameDocumentNavigationForMainFrame(SameDocumentNavigationType) override;
WKContentView *m_contentView;
WKWebView *m_webView;
{
}
+void PageClientImpl::didSameDocumentNavigationForMainFrame(SameDocumentNavigationType)
+{
+}
+
} // namespace WebKit
#endif // PLATFORM(IOS)
virtual void didFirstVisuallyNonEmptyLayoutForMainFrame() override;
virtual void didFinishLoadForMainFrame() override;
+ virtual void didSameDocumentNavigationForMainFrame(SameDocumentNavigationType) override;
virtual void removeNavigationGestureSnapshot() override;
WKView *m_wkView;
[m_wkView _didFinishLoadForMainFrame];
}
+void PageClientImpl::didSameDocumentNavigationForMainFrame(SameDocumentNavigationType type)
+{
+ [m_wkView _didSameDocumentNavigationForMainFrame:type];
+}
+
void PageClientImpl::removeNavigationGestureSnapshot()
{
[m_wkView _removeNavigationGestureSnapshot];
#define ViewGestureController_h
#include "MessageReceiver.h"
+#include "SameDocumentNavigationType.h"
#include "WeakObjCPtr.h"
#include <WebCore/FloatRect.h>
#include <wtf/RetainPtr.h>
void didFirstVisuallyNonEmptyLayoutForMainFrame();
void didFinishLoadForMainFrame();
+ void didSameDocumentNavigationForMainFrame(SameDocumentNavigationType);
#else
void installSwipeHandler(UIView *gestureRecognizerView, UIView *swipingView);
void setAlternateBackForwardListSourceView(WKWebView *);
#endif
#if PLATFORM(MAC)
+ RunLoop::Timer<ViewGestureController> m_swipeWatchdogAfterFirstVisuallyNonEmptyLayoutTimer;
+
double m_magnification;
WebCore::FloatPoint m_magnificationOrigin;
bool m_swipeWaitingForVisuallyNonEmptyLayout;
bool m_swipeWaitingForRenderTreeSizeThreshold;
bool m_swipeWaitingForRepaint;
+ bool m_swipeInProgress;
#else
UIView *m_liveSwipeView;
RetainPtr<UIView> m_liveSwipeViewClippingView;
static const float minimumScrollEventRatioForSwipe = 0.5;
static const float swipeSnapshotRemovalRenderTreeSizeTargetFraction = 0.5;
-static const std::chrono::seconds swipeSnapshotRemovalWatchdogDuration = 3_s;
+static const std::chrono::seconds swipeSnapshotRemovalWatchdogDuration = 5_s;
+static const std::chrono::seconds swipeSnapshotRemovalWatchdogAfterFirstVisuallyNonEmptyLayoutDuration = 3_s;
@interface WKSwipeCancellationTracker : NSObject {
@private
: m_webPageProxy(webPageProxy)
, m_activeGestureType(ViewGestureType::None)
, m_swipeWatchdogTimer(RunLoop::main(), this, &ViewGestureController::swipeSnapshotWatchdogTimerFired)
+ , m_swipeWatchdogAfterFirstVisuallyNonEmptyLayoutTimer(RunLoop::main(), this, &ViewGestureController::swipeSnapshotWatchdogTimerFired)
, m_lastMagnificationGestureWasSmartMagnification(false)
, m_visibleContentRectIsValid(false)
, m_frameHandlesMagnificationGesture(false)
, m_swipeWaitingForVisuallyNonEmptyLayout(false)
, m_swipeWaitingForRenderTreeSizeThreshold(false)
, m_swipeWaitingForRepaint(false)
+ , m_swipeInProgress(false)
{
m_webPageProxy.process().addMessageReceiver(Messages::ViewGestureController::messageReceiverName(), m_webPageProxy.pageID(), *this);
}
m_webPageProxy.navigationGestureDidBegin();
m_activeGestureType = ViewGestureType::Swipe;
+ m_swipeInProgress = true;
CALayer *rootContentLayer = m_webPageProxy.acceleratedCompositingRootLayer();
m_swipeCancellationTracker = nullptr;
+ m_swipeInProgress = false;
+
CALayer *rootLayer = m_webPageProxy.acceleratedCompositingRootLayer();
[rootLayer setShadowOpacity:0];
m_webPageProxy.navigationGestureDidEnd(true, *targetItem);
m_webPageProxy.goToBackForwardItem(targetItem);
+
+ m_swipeWatchdogTimer.startOneShot(swipeSnapshotRemovalWatchdogDuration.count());
}
void ViewGestureController::didHitRenderTreeSizeThreshold()
{
- if (m_activeGestureType != ViewGestureType::Swipe)
+ if (m_activeGestureType != ViewGestureType::Swipe || m_swipeInProgress)
return;
m_swipeWaitingForRenderTreeSizeThreshold = false;
void ViewGestureController::didFirstVisuallyNonEmptyLayoutForMainFrame()
{
- if (m_activeGestureType != ViewGestureType::Swipe)
+ if (m_activeGestureType != ViewGestureType::Swipe || m_swipeInProgress)
return;
m_swipeWaitingForVisuallyNonEmptyLayout = false;
if (!m_swipeWaitingForRenderTreeSizeThreshold)
removeSwipeSnapshotAfterRepaint();
- else
- m_swipeWatchdogTimer.startOneShot(swipeSnapshotRemovalWatchdogDuration.count());
+ else {
+ m_swipeWatchdogAfterFirstVisuallyNonEmptyLayoutTimer.startOneShot(swipeSnapshotRemovalWatchdogAfterFirstVisuallyNonEmptyLayoutDuration.count());
+ m_swipeWatchdogTimer.stop();
+ }
}
void ViewGestureController::didFinishLoadForMainFrame()
{
- if (m_activeGestureType != ViewGestureType::Swipe)
+ removeSwipeSnapshotAfterRepaint();
+}
+
+void ViewGestureController::didSameDocumentNavigationForMainFrame(SameDocumentNavigationType type)
+{
+ if (type != SameDocumentNavigationSessionStateReplace && type != SameDocumentNavigationSessionStatePop)
return;
removeSwipeSnapshotAfterRepaint();
void ViewGestureController::removeSwipeSnapshotAfterRepaint()
{
- if (m_activeGestureType != ViewGestureType::Swipe)
+ if (m_activeGestureType != ViewGestureType::Swipe || m_swipeInProgress)
return;
if (m_swipeWaitingForRepaint)
m_swipeWaitingForRepaint = false;
m_swipeWatchdogTimer.stop();
+ m_swipeWatchdogAfterFirstVisuallyNonEmptyLayoutTimer.stop();
if (m_activeGestureType != ViewGestureType::Swipe)
return;