g1455

How it works

One host captures the backdrop once for every glass surface, only when something under the glass changed.

Most glass packages put a BackdropFilter on every surface, which means the engine reads the backdrop once per surface on every frame. g1455 takes a different route, built for cost first: one capture for the whole screen, taken only when it has to be, and a blur that comes almost for free.

Knowing the route helps you predict what is cheap and what is not, which is most of what there is to know about performance with this package.

One host, one capture

A GlassHost records what is painted under all of its glass into one atlas, at a resolution picked against a measured quality budget. Every surface then samples its own slot of that atlas and draws the refraction, blur, tint and rim in one shader pass.

So ten surfaces do not mean ten reads of the backdrop. They mean one capture and ten draws.

A capture only when something changed

The host walks the composited layer tree. When nothing under the glass changed, it keeps the capture it already has. That covers a still screen, and a moving glass over content that stays put.

Keeping the capture is the default, and it is the biggest saving in the package: 79.4% and 66.3% of the route's added cost on Adreno, 97.8% on Metal.

What triggers a new capture:

  • content under the glass repaints: a list scrolls under a bar, an animation plays behind a card, a video runs;
  • the glass appears, disappears, resizes or moves to a new place;
  • a surface's materialize animates, because that changes the blur.

What does not:

  • a still screen, however much glass it has;
  • glass moving inside a GlassTravel region over still content, such as a slider's knob, a dragged lens or orbiting blobs;
  • a blinking caret or typing in a text field;
  • repaints that happen away from every glass surface.

The blur is a downscale

A capture taken at 1/N of the screen's resolution and scaled back up is a Gaussian blur of σ ≈ N/2, to within about 1%, at a fraction of the price of a real Gaussian. The host picks the downscale for each finish against measured quality tables: a blurry finish such as frosted tolerates a smaller capture, and clear glass, which has no blur, needs a sharper one.

What it costs

Measured costs, each on its own platform, because the platforms are not comparable:

platform glass vs stock Material engine BackdropFilter.grouped
Android, Impeller/Vulkan, Adreno 830 (GPU cycles) ×0.99…1.08 ×1.78…3.15
iPad, Impeller/Metal (GPU ms, scrolling screen) ×1.93…2.02, or ×1.46…1.54 with thermal throttling —

What this means for your app

  • A still screen with glass costs almost nothing beyond drawing the glass itself.
  • Glass that moves over still content belongs in a GlassTravel region. The built-in switch, slider, segmented control and tab bar already do this.
  • Content that changes under glass costs one capture per changed frame. That is the honest price of a list scrolling under a bar, and it is still one capture, not one per surface.
  • Each surface is still one draw, and the overhead grows faster than the count. Keep glass in the navigation and controls layers. See Performance.
  • Glass on top of other glass needs one capture per level. Glass nested inside glass gets that automatically; sibling glass that floats above other glass needs GlassAbove.

Note

If you have reason to distrust the change detection, GlassHost(content: GlassContentDeclaration.undeclared) re-captures every frame. It is the most expensive thing the package can be asked to do; use it to rule the detection out, not to ship.