From MozillaWiki
Jump to: navigation, search


Under consideration.


  • Last modified: July 13, 2010
  • Authors: Tuomas Ojamies (Nokia)
  • Contributors: Oleg Beletski (Nokia), Karl Tomlinson (Mozilla)

Problem Summary

Plugin should receive notification from NPAPI about visibility changes.


  1. Visibility notify event as proposed here.
  2. Using 0x0 ClipRect in SetWindow as already implemented for OS X.


This specification describes a way to pass visibility notifications from browsre to plugin. With visibility notification we mean a notification from browser to plugin when plugin visibility is changed after page scrolling , tab switching, browser window being minimized or maximized or browser window going to foreground or to background.

Plugin can use these notifications to optimize its behavior. For example many rendering operations can be skipped if plugin is not visible. For plugins that are in windowed mode these events have been available from UI toolkits but more generic system is needed. Windowless plugins do not have access to UI toolkits and have no way to receive these events.

There has been suggested that every plugin that would need such service would have to find its own way to implement it but this seems unnecessary as there is architecturally clean way to do this.

For example if there is a web page that has 5 plugin instances, each using 20% of CPU. Any user interaction will be sluggish. However if these instances are located so that only one of them can be visible, and if visibility information is used to pause invisible plugins, then the CPU usage would be 20%. This would improve the browsing experience a lot. Because of the small displays and weak CPU that are typically used on mobile devices this is realistic example.


The Browser can report VisibilityNotify events for the NPP_HandleEvent function of plugin to signal obscured, partially obscured and unobscured states (VisibilityFullyObscured, VisibilityPartiallyObscured and VisibilityUnobscured).

A window is visible if and only if someone looking at the screen can actually see it or a part of it. If browser is not able to distinguish obscured and partially obscured plugins then partially obscured plugin should be treated as unobscured. When no signals have been sent then plugin is considered to be unobscured.

Plugins running in windowed mode can still rely on existing way of notifications via windows events.

In addition browser can provide proposed notification mechanism via NPAPI so that plugins are able to rely on a single method for receiving these events. Eventually it would be up to the plugin to decide whether to interpret visibility events from the window or NPP_HandleEvent or both.