Asynchronous Plugin Initialization improves plugin startup in Firefox
When you check out telemetry data that Mozilla collects about hangs in its Firefox web browser, you will notice that plugin-related issues are over-represented there.
Update: The situation has changed significantly in recent years. Firefox dropped support for nearly all plugins in recent versions of the browser. Adobe Flash support is discontinued at the end of 2020 and that marks the end of plugin support in the Firefox web browser. End
Plugins in this context refers exclusively to NPAPI plugins that the Firefox web browser supports such as Adobe Flash.
Whenever a Firefox user visits a web page that runs code that requires plugins, plugins need to be initialized.
Aaron Klotz broke the steps down on his blog post back in June 2014:
- Launch of plugin-container process.
- Calling the function NP_Initialize to load the plugin.
- Calling the function NPP_New to create instances.
- Calling the function NPP_NewStream for data loading instances.
- For scriptable instances, call NPP_GetValue.
The most frequent hang cause is the creation of the plugin-container process followed by the plugin startup process taking too long to go through the steps listed above.
Aaron worked on improvements for the process in 2014 by initializing plugins asynchronously. In particular, it will load the first four steps asynchronously to improve loading time and reduce the likelihood of hangs or slow downs caused by the initialization.
Check out the demo video below which shows an early prototype that Aaron created. It demonstrates the loading of a page using Flash with and without asynchronous plugin initialization.
As you can see in the demo, loading is faster and smoother with asynchronous plugin initialization enabled in the browser.
Mozilla launched the feature in Nightly yesterday. This means that Firefox Nightly users can use it right now, provided they have updated the version of the browser to the latest build.
It needs to be enabled before it can be used though:
- Type about:config in the address bar and hit enter.
- Confirm that you will be careful if a prompt is displayed.
- Search for dom.ipc.plugins.asyncInit using the search form at the top.
- Double-click the name that appears in search to set it to true.
This enables the feature and should improve plugin initialization in Firefox significantly. The feature is being tested currently and Mozilla asks users to file bugs if they notice issues while using Firefox with it enabled.
It is not clear yet when it will land in the stable version of the browser but I'd expect it to be released to it in the first half of 2015.
Firefox users who load sites that use plugins regularly in the browser should see noticeable improvements in loading time and a decrease in hangs or slow downs after activating the new feature.
Just tried it out for a bit, seems they are still working out some problems as expected.
As quite a few flash related online games will get stuck loading.
Works again when disabled, so i guess i will wait until i read a message about that being solved, or they enable it themselfs.
Thanks for the great article though.
Have a great 2015, Martin!! And thanks a lot for all your work!
Sounds good to me. :)
“…process taking to long…” Too big, too small, too long, *two O’s.* :)
Unfortunately, on Ubuntu PPA, Firefox Nightly is not yet released.