Performance/Addons/BestPractices: Difference between revisions

Remarks about nsIThread.dispatch disabled in Firefox 4 for javascript runnables
No edit summary
(Remarks about nsIThread.dispatch disabled in Firefox 4 for javascript runnables)
Line 130: Line 130:
==Consider using web workers and/or nsIThread==
==Consider using web workers and/or nsIThread==
The latter is admittedly difficult to get right (no DOM access, store references to avoid garbage collector hazards). Web workers are far less "dangerous". See MDC for some examples. If you use threads then make sure to test on a multi-core system. A single core system will hide crashed.
The latter is admittedly difficult to get right (no DOM access, store references to avoid garbage collector hazards). Web workers are far less "dangerous". See MDC for some examples. If you use threads then make sure to test on a multi-core system. A single core system will hide crashed.
Please note that as of Firefox 4, nsIThread.dispatch does not accept nsIRunnable-s implemented in Javascript and created on a different thread than the thread you're trying to dispatch the nsIRunnable to. This limitation was implemented to avoid crashes caused by changes especially to the Javascript strings implementation.
This effectively means that javascript extensions cannot use the nsIThread API anymore to execute own jobs on different threads than the main thread.
Consider Web/ChromeWorker as a replacement, which are severely limited in what you can do with them, or just don't use threads.


==Cache Stringbundles==
==Cache Stringbundles==
33

edits