@@ -583,6 +583,7 @@ WebPage::WebPage(PageIdentifier pageID, WebPageCreationParameters&& parameters)
583583#if ENABLE(APP_HIGHLIGHTS)
584584 , m_appHighlightsVisible(parameters.appHighlightsVisible)
585585#endif
586+ , m_renderSingleFrameIfRenderingPausedTimer(*this , &WebPage::renderSingleFrameIfRenderingPausedTimerFired)
586587{
587588 ASSERT (m_identifier);
588589 WEBPAGE_RELEASE_LOG (Loading, " constructor:" );
@@ -3844,6 +3845,9 @@ void WebPage::resume(CompletionHandler<void(bool)>&& completionHandler)
38443845 Ref<ResumeEventNotifier> notifier = adoptRef (*new ResumeEventNotifier ());
38453846 notifier->setCompletionHandler ([this , completionHandler = std::exchange (completionHandler, { })] () mutable {
38463847 m_isLifecycleSuspended = false ;
3848+ // This is the last step of the resume before moving into hidden state, so we want to request
3849+ // a single frame here.
3850+ m_drawingArea->renderSingleFrameIfRenderingPaused ();
38473851 completionHandler (true );
38483852 });
38493853
@@ -7259,6 +7263,15 @@ void WebPage::dispatchDidReachLayoutMilestone(OptionSet<WebCore::LayoutMilestone
72597263 updateIntrinsicContentSizeIfNeeded (mainFrameView ()->autoSizingIntrinsicContentSize ());
72607264 }
72617265
7266+ if (milestones.contains (DidFirstLayout) && m_page->settings ().pageLifecycleAPIEnabled () && !m_isLifecycleSuspended) {
7267+ // The page finished its first layout. This can happen when the page is loaded for the first time or
7268+ // when the view is resuming. If m_isLifecycleSuspended is false it means that it's the first load
7269+ // so this is the point where we want to request a single frame if the view is hidden. We cannot try
7270+ // to render the frame directly because scripts are disallowed at this point, and we may need them when
7271+ // rendering, so request the frame with a timer.
7272+ m_renderSingleFrameIfRenderingPausedTimer.startOneShot (0_s);
7273+ }
7274+
72627275 send (Messages::WebPageProxy::DidReachLayoutMilestone (milestones));
72637276}
72647277
@@ -8250,6 +8263,11 @@ void WebPage::clearNotificationPermissionState()
82508263}
82518264#endif
82528265
8266+ void WebPage::renderSingleFrameIfRenderingPausedTimerFired ()
8267+ {
8268+ m_drawingArea->renderSingleFrameIfRenderingPaused ();
8269+ }
8270+
82538271} // namespace WebKit
82548272
82558273#undef WEBPAGE_RELEASE_LOG
0 commit comments