Static Widgets

HTML widgets are rendered by the player using a Web browser (WebKit or Chromium). Running a browser usually requires a great amount of system resources (usually RAM memory). This means that if you use multiple HTML widgets the system might run out of memory and performance will be affected.

There are some types of widgets though, that are not really required to keep running on a Web browser after they have initially been rendered. These widgets are usually the ones that their content will not change or change rarely. Some examples are:

  • A rich text widget (static, the text and formatting will not change)
  • Shape widgets (static, the shape and its properties will not change)
  • A date widget (semi-static, the date changes once per day)
  • A weather widget (semi-static, update every few hours)

As an optimization for these kinds of widgets, we provide a mechanism that allows widgets to instruct the player to capture a snapshot after they have been finished rendering their content. Once a snapshot has been captured, the system will render it using our resource-efficient image player, instead of a full-fledged, resource-hungry browser.

Taking advantage of this mechanism is actually quite simple. The idea is that once your widget has finished rendering, it should change the window title to notify the player that it can get a snapshot of the widget.

Static Widgets

When your widget is ready for the player to get a snapshot, change the window title as seen below:

document.title = '{"ready_for_cache": true}'

Semi-static Widgets

For the case of semi-static widgets, the title must also specify for how long the cached snapshot will be valid in seconds. The following example will notify the player to get a snapshot and consider it valid for the next hour:

document.title = '{"ready_for_cache": true, "valid_for": 3600}'

The player will automatically take care of starting the widget when the cached snapshot is no longer valid.

Notes

  • The cache is persistent and it is stored on the SD card.
  • If you make any changes to your widget on the Web portal, any cached snapshots will be deleted and new ones will be created.
  • The widget will have about 30 seconds after it has been started to set the title to notify the player to get a snapshot. If the title is not changed, the widget will be rendered normally using the Web rendering engine (WebKit or Chromium).
  • When static widget snapshots are created, a blinking message “Preparing content” will appear on the bottom right corner of the screen.