Re: Daniel Pitts on JSObject and FireFox
Daniel Pitts wrote:
It was state-of-the-art when I posted it. Since then, I've also run into
what appears to be threading issues causing firefox to crash :-( It's
unfortunate because every other aspect of our tool was targeting firefox.
I just noticed this on Sun's site. Related?
Because the DOM of each browser is implemented differently, DOM access
is not expected to be thread safe. Accessing implementation of DOM
objects in this specification must be restricted on the DOM access
dispatch thread only, so thread safely can be ensured. To accomplish
that, code accessing the DOM objects must be scoped within the
DOMAction.run() block. To invoke the action, either
DOMService.invokeAndWait() or DOMService.invokeLater() should be used,
so that DOMAction.run() will be executed in the DOM access dispatch thread.
Although implementations of DOM objects should not be called outside the
DOMAction.run() block, the application may cache these DOM objects
around as instance member of a class, or pass these DOM objects between
threads. However, caching the DOM objects as static members of any
object is prohibited, since static members tend to stay around much
longer than the lifecycle of the underlying DOM object.
The only object in the Common DOM classes that can be called from any
thread is DOMService. Access to other objects in the Common DOM classes
is restricted within the DOMAction.run() block; otherwise, an exception
will be thrown."