<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>208780</bug_id>
          
          <creation_ts>2020-03-07 18:15:40 -0800</creation_ts>
          <short_desc>No need to schedule/unschedule style recalcs and layouts inside of a rendering update</short_desc>
          <delta_ts>2025-07-07 07:54:30 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Layout and Rendering</component>
          <version>Safari Technology Preview</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=201018</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=201019</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Simon Fraser (smfr)">simon.fraser</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>koivisto</cc>
    
    <cc>rniwa</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1627401</commentid>
    <comment_count>0</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2020-03-07 18:15:40 -0800</bug_when>
    <thetext>We waste time updating timers during a rendering update:

Style recalc timer:

CFRunLoopTimerSetNextFireDate
WebCore::MainThreadSharedTimer::setFireInterval(WTF::Seconds)
WebCore::ThreadTimers::updateSharedTimer()
WebCore::TimerBase::setNextFireTime(WTF::MonotonicTime)
WebCore::TimerBase::start(WTF::Seconds, WTF::Seconds)
WebCore::TimerBase::startOneShot(WTF::Seconds)
WebCore::Document::scheduleStyleRecalc()
WebCore::Node::updateAncestorsForStyleRecalc()
WebCore::Node::invalidateStyle(WebCore::Style::Validity, WebCore::Style::InvalidationMode)
WebCore::Element::invalidateStyle()
WebCore::StyledElement::invalidateStyleAttribute()
WebCore::InlineCSSStyleDeclaration::didMutate(WebCore::PropertySetCSSStyleDeclaration::MutationType)
WebCore::PropertySetCSSStyleDeclaration::setPropertyInternal(WebCore::CSSPropertyID, WTF::String const&amp;, bool)
WebCore::CSSStyleDeclaration::setNamedItem(WTF::AtomString const&amp;, WTF::String, bool&amp;)
WebCore::JSCSSStyleDeclaration::put(JSC::JSCell*, JSC::JSGlobalObject*, JSC::PropertyName, JSC::JSValue, JSC::PutPropertySlot&amp;)
JSC::JSCell::putInline(JSC::JSGlobalObject*, JSC::PropertyName, JSC::JSValue, JSC::PutPropertySlot&amp;)
JSC::JSValue::putInline(JSC::JSGlobalObject*, JSC::PropertyName, JSC::JSValue, JSC::PutPropertySlot&amp;)
operationPutByIdNonStrict
0x4ed07c0002cd
vmEntryToJavaScript
JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*)
JSC::Interpreter::executeCall(JSC::JSGlobalObject*, JSC::JSObject*, JSC::CallType, JSC::CallData const&amp;, JSC::JSValue, JSC::ArgList const&amp;)
JSC::call(JSC::JSGlobalObject*, JSC::JSValue, JSC::CallType, JSC::CallData const&amp;, JSC::JSValue, JSC::ArgList const&amp;)
JSC::call(JSC::JSGlobalObject*, JSC::JSValue, JSC::CallType, JSC::CallData const&amp;, JSC::JSValue, JSC::ArgList const&amp;, WTF::NakedPtr&lt;JSC::Exception&gt;&amp;)
JSC::profiledCall(JSC::JSGlobalObject*, JSC::ProfilingReason, JSC::JSValue, JSC::CallType, JSC::CallData const&amp;, JSC::JSValue, JSC::ArgList const&amp;, WTF::NakedPtr&lt;JSC::Exception&gt;&amp;)
WebCore::JSExecState::profiledCall(JSC::JSGlobalObject*, JSC::ProfilingReason, JSC::JSValue, JSC::CallType, JSC::CallData const&amp;, JSC::JSValue, JSC::ArgList const&amp;, WTF::NakedPtr&lt;JSC::Exception&gt;&amp;)
WebCore::JSEventListener::handleEvent(WebCore::ScriptExecutionContext&amp;, WebCore::Event&amp;)
WebCore::EventTarget::innerInvokeEventListeners(WebCore::Event&amp;, WTF::Vector&lt;WTF::RefPtr&lt;WebCore::RegisteredEventListener, WTF::DumbPtrTraits&lt;WebCore::RegisteredEventListener&gt; &gt;, 1ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc&gt;, WebCore::EventTarget::EventInvokePhase)
WebCore::EventTarget::fireEventListeners(WebCore::Event&amp;, WebCore::EventTarget::EventInvokePhase)
WebCore::WindowEventContext::handleLocalEvents(WebCore::Event&amp;, WebCore::EventTarget::EventInvokePhase) const
WebCore::dispatchEventInDOM(WebCore::Event&amp;, WebCore::EventPath const&amp;)
WebCore::EventDispatcher::dispatchEvent(WebCore::Node&amp;, WebCore::Event&amp;)
WebCore::Node::dispatchEvent(WebCore::Event&amp;)
WebCore::Document::runScrollSteps()
WebCore::Page::updateRendering()::$_13::operator()(WebCore::Document&amp;) const

CFRunLoopTimerSetNextFireDate
WebCore::MainThreadSharedTimer::setFireInterval(WTF::Seconds)
WebCore::ThreadTimers::updateSharedTimer()
WebCore::TimerBase::setNextFireTime(WTF::MonotonicTime)
WebCore::TimerBase::stop()
WebCore::Document::unscheduleStyleRecalc()
WebCore::Document::resolveStyle(WebCore::Document::ResolveStyleType)
WebCore::Document::updateStyleIfNeeded()
WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive()
WebCore::Page::layoutIfNeeded()
WebCore::Page::updateRendering()
WebKit::WebPage::updateRendering()


Layout timer:

WebCore::MainThreadSharedTimer::setFireInterval(WTF::Seconds)
WebCore::ThreadTimers::updateSharedTimer()
WebCore::TimerBase::setNextFireTime(WTF::MonotonicTime)
WebCore::TimerBase::start(WTF::Seconds, WTF::Seconds)
WebCore::TimerBase::startOneShot(WTF::Seconds)
WebCore::FrameViewLayoutContext::scheduleLayout()
WebCore::scheduleRelayoutForSubtree(WebCore::RenderElement&amp;)
WebCore::RenderObject::markContainingBlocksForLayout(WebCore::ScheduleRelayout, WebCore::RenderElement*)
WebCore::RenderElement::setNeedsPositionedMovementLayout(WebCore::RenderStyle const*)
WebCore::RenderElement::styleDidChange(WebCore::StyleDifference, WebCore::RenderStyle const*)
WebCore::RenderLayerModelObject::styleDidChange(WebCore::StyleDifference, WebCore::RenderStyle const*)
WebCore::RenderBox::styleDidChange(WebCore::StyleDifference, WebCore::RenderStyle const*)
WebCore::RenderBlock::styleDidChange(WebCore::StyleDifference, WebCore::RenderStyle const*)
WebCore::RenderBlockFlow::styleDidChange(WebCore::StyleDifference, WebCore::RenderStyle const*)
WebCore::RenderElement::setStyle(WebCore::RenderStyle&amp;&amp;, WebCore::StyleDifference)
WebCore::RenderTreeUpdater::updateRendererStyle(WebCore::RenderElement&amp;, WebCore::RenderStyle&amp;&amp;, WebCore::StyleDifference)

WebCore::TimerBase::stop()
WebCore::FrameViewLayoutContext::layout()
WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive()
WebCore::Page::layoutIfNeeded()
WebCore::Page::updateRendering()
WebKit::WebPage::updateRendering()


Scrolling tree commit timer:
WebCore::TimerBase::start(WTF::Seconds, WTF::Seconds)
WebCore::TimerBase::startOneShot(WTF::Seconds)
WebCore::ScrollingCoordinatorMac::scheduleTreeStateCommit()
WebCore::AsyncScrollingCoordinator::scrollingStateTreePropertiesChanged()
WebCore::ScrollingStateTree::setHasChangedProperties(bool)
WebCore::ScrollingStateNode::setPropertyChanged(unsigned int)
WebCore::ScrollingStateScrollingNode::setScrollPosition(WebCore::FloatPoint const&amp;)
WebCore::AsyncScrollingCoordinator::setScrollingNodeScrollableAreaGeometry(unsigned long long, WebCore::ScrollableArea&amp;)
WebCore::RenderLayerCompositor::updateScrollingNodeForScrollingRole(WebCore::RenderLayer&amp;, WebCore::ScrollingTreeState&amp;, WTF::OptionSet&lt;WebCore::RenderLayerCompositor::ScrollingNodeChangeFlags&gt;)
WebCore::RenderLayerCompositor::updateScrollCoordinationForLayer(WebCore::RenderLayer&amp;, WebCore::RenderLayer const*, WebCore::ScrollingTreeState&amp;, WTF::OptionSet&lt;WebCore::RenderLayerCompositor::ScrollingNodeChangeFlags&gt;)
WebCore::RenderLayerCompositor::updateBackingAndHierarchy(WebCore::RenderLayer&amp;, WTF::Vector&lt;WTF::Ref&lt;WebCore::GraphicsLayer, WTF::DumbPtrTraits&lt;WebCore::GraphicsLayer&gt; &gt;, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc&gt;&amp;, WebCore::RenderLayerCompositor::UpdateBackingTraversalState&amp;, WebCore::ScrollingTreeState&amp;, WTF::OptionSet&lt;WebCore::RenderLayerCompositor::UpdateLevel&gt;)
WebCore::RenderLayerCompositor::updateCompositingLayers(WebCore::CompositingUpdateType, WebCore::RenderLayer*)
WebCore::FrameView::updateCompositingLayersAfterLayout()
WebCore::FrameView::didLayout(WTF::WeakPtr&lt;WebCore::RenderElement&gt;)
WebCore::FrameViewLayoutContext::layout()
WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive()
WebCore::Page::layoutIfNeeded()
WebCore::Page::updateRendering()
WebKit::WebPage::updateRendering()

None of these are necessary.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1628541</commentid>
    <comment_count>1</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2020-03-10 23:01:04 -0700</bug_when>
    <thetext>Should we add some flag on Document to indicate that we&apos;re in the middle of rendering update?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1628543</commentid>
    <comment_count>2</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2020-03-10 23:01:58 -0700</bug_when>
    <thetext>Also, in theory, we should never have to schedule style recalc / layout anymore directly.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1968767</commentid>
    <comment_count>3</comment_count>
    <who name="Rob Buis">rbuis</who>
    <bug_when>2023-07-29 11:20:36 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/16213</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1968859</commentid>
    <comment_count>4</comment_count>
    <who name="Rob Buis">rbuis</who>
    <bug_when>2023-07-31 08:48:14 -0700</bug_when>
    <thetext>I think the scheduleLayout case is not happening anymore, at least I could not reproduce it.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>