[Webkit-unassigned] [Bug 23662] Browser hangs for a long time first time a link is clicked

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sat Jan 31 03:46:05 PST 2009


https://bugs.webkit.org/show_bug.cgi?id=23662


mrowe at apple.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mrowe at apple.com




------- Comment #1 from mrowe at apple.com  2009-01-31 03:46 PDT -------
The following JS is run when one of the links is clicked:

function show_elems(filt)
{
        var all = $('.game-list .games > ul > li').hide();

        if (filt['soft'] != '') all = all.filter('.'+filt['soft']);
        if (filt['cat'] != '')  all = all.filter('.'+filt['cat']);

        all.show();
}

The call to jQuery's .hide() method appears to be responsible for much of the
hang.  It is implemented as follows:

for ( var i = 0, l = this.length; i < l; i++ ){
        var old = jQuery.data(this[i], "olddisplay");
        if ( !old && old !== "none" )
                jQuery.data(this[i], "olddisplay", jQuery.css(this[i],
"display"));
        this[i].style.display = "none";
}

jQuery.css is basically a wrapper around getComputedStyle.  This is looping
over each element in the set, querying its computed style for the "display"
property, then setting the display property to "none".  For this particular
page there are approximately 1000 entries being iterated over.  The problem
with this code is that modifying the style of a node causes the document layout
info to need updating.  CSSComputedStyleDeclaration::getPropertyCSSValue always
ensures that the document layout info is up to date before returning a value,
which means that we're recalculating layout around 1000 times simply to hide a
bunch of elements.


-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list