D
David Mark
Stefan said:If that's what you meant, then I misunderstood you, too. "Exiting an
execution context" is ambiguous - I also thought you meant "returning
from an execution context", either explicitly or when there are no more
statements to process, instead of "entering a new execution context".
(OTOH, there may be no practical difference, because both are connected)
To be precise, I mean leaving an execution context on either calling
another function or on finishing execution of the last statement (at
which point it returns to the caller's execution context, assuming the
call stack is not exhausted at that point).
I've noticed unexpected redraws in Opera in the past, when they didn't
happen in other browsers on the same PC. Maybe Opera really does handle
things differently here, or maybe all browsers do this, as you say, but
with a different heuristic/logic behind the decision.
There's no telling exactly when any given browser will do it. But they
won't do it at all unless you exit an execution context. That much I
know. I can't speak for every browser, but I've tested more than my
share over the years.
In any case, this
effect is not easy to prove*, and there are still no official documents
describing when a redraw is likely to happen (before the thread ends).
Correct. You have to draw upon experience. I have also discussed this
with other experienced developers (and some of those discussions are in
the archive).
You said you could easily produce a test case for your PC.
Sure. Set a previously hidden element's visibility style to "visible"
(assuming it does not have a display style of "none" of course). Then
call a function that clips it (or sizes it or whatever). Try it in
various browsers (as mentioned slower or burdened PC's seem to be the
best bet) and watch for a flicker of the full element before the clip
(or size or whatever). Once reproduced, it is trivial to fix by setting
the subsequent style without calling a function.
I most recently ran into this when dealing with IE's filter style.
Displaying the element just prior to calling a function that adjusted
the filter style resulted in a momentary flash of the unfiltered
element. This happened virtually every time (on at least one machine
anyway). Setting the filter style in the same function that displayed
the element (with no function calls in between) fixed it for good. Of
course, this only happened when styling a particular DOM structure. The
same code operating on a different structure (or even the same structure
in a different document) did not. So trying to track such behavior will
drive you nuts. It's best to look at the code, rather than the browser
window (assuming you know what to look for).
It would be
helpful if you could put this test online, so that more people with
different configurations can try it and share their results.
As it happens, the one I describe above is online, but with a workaround
in place. I used a workaround of setting the opacity to 0, then
applying the other filter, calling the function that shows the element
and then setting the opacity back on return from that function (unless
the effect is fade of course, in which case I let it be). Eventually I
will update the library code as I can see where the potential for a
problem lies (and it had lay dormant for years until I started on the
Alert example). As mentioned, this never happened on another page that
shows/hides the same DOM structure with the same code (the Build Test
page has no such workaround). Basically, a fade-in on the latter page
was fine, but on the Examples page (in IE8 only), I got a flicker of the
fully opaque element. But it is no mystery as the animation code
clearly has one place where this can happen.
Hit my Examples page with IE8 and see the note in the alert section.
There's enough explanation there to try to reproduce the issue in a
sandbox. But your sandbox may well have to mimic the Examples page (and
your PC may well have to be similar to my test machine). FWIW, IE8 is a
major dog on that particular machine and the Examples page is fairly
long-winded with tons of form controls.
http://www.cinsoft.net/mylib-examples.html#myalert
Perhaps I will put up a test version without the workaround when I get a
chance, but no promises. I am pretty swamped these days and I am not
particularly curious as I know exactly where the potential for a problem
lies.
*) apart from reading the source, where that is possible. Given time, I
can find my way around the Mozilla and Webkit sources, but these days
it's mostly a maze of macros and arcane optimizations. I don't go there
unless I absolutely have to. My last encounter with Mozilla code left me
scarred and traumatized for life.
Don't bother (not for this anyway). As an aside, I've had previous
issues like this with various FF versions (again, usually on slow
machines). The solution was always the same.
I did, but came up empty. I really wish Google would stop treating
Usenet search like an unwanted child.
Yes, GG sucks. I got lucky and found one of the threads I was thinking of:-
http://groups.google.com/group/comp...39923b4b9d/b09cb6f082f1487e?#b09cb6f082f1487e
Their web search is great, almost
psychic at times, but with their Usenet index, I sometimes can't even
find a message when I know the group and the exact subject.
Tell me about it.
That thing
is seriously broken. "Searching the archive" is a good idea but not a
guarantee for success.
It's unfortunate. But you can use their Web search as well as these
posts echo all over the place.
I don't doubt it, but that's still anecdotal evidence from one person.
We should be able to do better than that.
Possibly. As mentioned, it's one of those issues that shows up
sporadically. I only know the way to avoid it entirely, not the way to
reproduce it reliably.
BTW, for those wondering, this does not qualify as a "quick answer". My
"insurance business" would go belly up if I had to give this much
detail for quick questions. The quick answer had been previously given
and is certainly enough to avoid the problem (though it does not
represent a proof of anything). Proofs (when possible) and history
lessons are extra.