What a scene costs

Most of what a scene costs is not the scene. This page has what was measured, and the properties that lower the cost. What keeps a phone's page smooth, the canvas in a browser and the conditions under which scenes draw less, is in Speed on phones.

Why

A scene that moves all the time is a standing cost: it is paid on every screen that shows it, for as long as it shows. The numbers below say where the time goes, so that the right thing is turned down.

Example

# lib/resources/application.yml
spring:
  flutter:
    scene:
      max-frame-rate: 30     # the ceiling of every scene
      pixel-ratio: 1.5       # the scenes' own; not set: the device's
      pause-off-screen: true
# lib/resources/application-android.yml: one frame that stands, on Android
spring:
  flutter:
    scene:
      render: still

The measurements

Measured on a page of Dota Passport (Chrome, Apple M5, a release build, canvas: page):

What helps

Property What it does
spring.flutter.scene.max-frame-rate The most frames a second any scene draws, 30 by default. maxFrameRate on a widget asks for fewer. 0 is as many as the screen shows, 60 to 144: each of them costs a frame
spring.flutter.scene.render: still One frame that stands, drawn again only when what it shows changes
spring.flutter.scene.pause-off-screen A scene scrolled off the screen stops drawing; true by default
spring.flutter.scene.pixel-ratio The scenes' own pixel ratio, under the device's: 1 on a screen of 3 draws a ninth of the pixels
spring.flutter.scene.canvas In a browser, where a frame of a scene goes: page (the default), layer or engine. With the last two Flutter does not draw the page for it. See The canvas in a browser
spring.flutter.scene.light-clustering: false Each mesh shades the lamps that reach it: no lamp textures made anew when a lamp comes into the view or leaves it, a frame of about 30 ms on an iPhone
spring.flutter.scene.when still or off while a condition holds: touch (a touch screen), slow (the scenes cost this device too much, decided before they show) or one of the app's. See Drawing less where it costs too much

When the system asks for less motion, every scene draws one frame that stands, whatever the properties say.

A value for one platform goes into its profile file, as everywhere: render: still in application-android.yml, or in the profile a debug run uses (application-debug.yml), where a frame costs several times a release's. See Platform profiles.

A cross-origin isolated page

The headers are Cross-Origin-Opener-Policy: same-origin and Cross-Origin-Embedder-Policy: require-corp. They are set on the host, and for flutter run under spring.flutter.web.dev-server.headers:

# lib/resources/application.yml
spring:
  flutter:
    web:
      dev-server:
        headers:
          Cross-Origin-Opener-Policy: same-origin
          Cross-Origin-Embedder-Policy: require-corp

require-corp forbids cross-origin resources without CORS: the server of a model at an address must allow the page's origin (see Models). The debug tab says whether the page is isolated. See The dev server of flutter run.

Where it costs most

See also