Table of Contents
Intro
HTML apps 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 apps, the system might run out of memory, and performance will be affected.
There are some types of apps, though, that are not really required to keep running on a Web browser after they have initially been rendered. These apps are usually the ones whose content will not change or change rarely. Some examples are:
- A rich text app (static, the text and formatting will not change)
- Shape apps (static, the shape and its properties will not change)
- A dating app (semi-static, the date changes once per day)
- A weather app (semi-static, update every few hours)
As an optimization for these kinds of apps, we provide a mechanism that allows apps to instruct the player to capture a snapshot after they have 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 app has finished rendering, it should change the window title to notify the player that it can get a snapshot of the app.
Static Apps
When your app is ready for the player to get a snapshot, change the window title as seen below:
document.title = '{"ready_for_cache": true}'
Semi-static Apps
For the case of semi-static apps, 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 start the app when the cached snapshot is no longer valid. Keep in mind that there are cases where the app may not always get optimized as semi-static. Your app should set the title when it is ready to get cached and then continue updating its data normally as if it was a regular html app.
Notes
- The cache is persistent, and it is stored on the SD card.
- If you make any changes to your app on the Web portal, any cached snapshots will be deleted, and new ones will be created.
- The app 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 app will normally be rendered using the Web rendering engine (WebKit or Chromium).
- When static app snapshots are created, a blinking message “Preparing content” will appear on the bottom right corner of the screen.