<FAQENTRY>I'm changing my page but nothing is changing on the screen. Why?</FAQENTRY>

V

VK

As per discussion in the thread
http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/117e4f3a30f4d1c3
I'm proposing to add new FAQ entry:

----------------------------------------------------------------
I'm changing my page but nothing is changing on the screen. Why?
----------------------------------------------------------------

You may be experiencing the repaint delay problem. All existing
browsers do not update graphics context (screen content) until after
the current execution is finished. Until it's finished the DOM changes
are being accumulated but not reflected on the screen. The most
commonly used way to overcome this problem is by using micro-breaks
over setTimeout.

/* repaint delay vulnerable coding : */
function someLongProcess() {
document.getElementById('LoadingMessage').style.visibility =
'visible';
doLongProcess();
document.getElementById('LoadingMessage').style.visibility =
'hidden';
}

In the sample above nothing will work as the coder would expect.
LoadingMessage DOM element will remain invisible on the screen until
after someLongProcess function is fully executed. Only after that all
graphics context changes will be applied in one bulk, so
LoadingMessage element will be changed to visible and to hidden right
after that, so for the viewer it will not appear at all.

/* repaint delay aware coding : */
function someLongProcess() {
document.getElementById('LoadingMessage').style.visibility =
'visible';
window.setTimeout(doLongProcess, 60);
}

function doLongProcess() {
// long process;
document.getElementById('LoadingMessage').style.visibility =
'hidden';
}

----------------------------------------------------------------

Some notes to the FAQ text:
1) I'm struggling to find the right term for "the current execution is
finished". It is not really finished - that can be a few processes
over setInterval for instance. "current thread" or "current flaw" is
bad IMHO as well as because of terminology confusion (JavaScript
doesn't implement threaded model). Ideas?

2) This issue is really a "bug qualifying feature" - it forces to use
modularity based not on the programming logic but on graphics engine
weakness. So I think to file a feature request to Bugzilla based on
this FAQ. It doesn't matter that "everyone does the same" - some day a
UA should appear that does it not.

3) If anyone has timÕ it would be interesting to check if the "soft
break" would works, so something like:

function someLongProcess() {

window.setTimeout("document.getElementById('LoadingMessage').style.visibility
= 'visible';", 60);
doLongProcess();
document.getElementById('LoadingMessage').style.visibility =
'hidden';
}

I can tell pretty sure that it will fail for synchronious XHR calls
where the suggested "hard break" is the only option. But maybe for
some other cases like the one in the thread I linked?


P.S. Yeah, I know... Started laud on rounding FAQ and ended up will
all another unrelated FAQ. The problem with the rounding FAQ is that
it is now in E=mc^2 state. I don't mean it's so genius :) I mean that
while the suggestion itself is short and simple, the explanation and
proof of "why?" requires a whole big article I have to write first.
But this FAQ is still in my schedule.
 
V

VK

As per discussion in the threadhttp://groups.google.com/group/comp.lang.javascript/browse_frm/thread...
I'm proposing to add new FAQ entry:

Any comments or is it accepted as it is?
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]>
, Wed, 14 Mar 2007 20:57:38, Richard Cornford
Why do you think an assertion of yours about your own intentions needs
acceptance (or, presumably, rejection)?


It is presumptuous for a failed FAQ maintainer to criticise the efforts
of one who is undoubtedly active.

VK's efforts can be judged easily enough by appearances and general
response3s - there is no need for you to do a general public vendetta.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top