Skip to content

Android / Mali: cold GPUCanvas shader linking delays first frames while Flutter stays responsive #673

Open

Description

@Linaks

Tested on a physical Redmi 14C (2409BRN2CY, ARM64, Android 15 / API 35) in Flutter Profile mode. The installed Android binary was verified as rive_native 0.2.0-dev.5+3 with rive 0.15.0-dev.5. The test used Factory.rive with the default Android offscreen Surface path.

With a fresh process, enter a screen that prepares scripted GPUCanvas surfaces serially. The first three surfaces did not complete native preparation before the app's roughly three-second warmup watchdog fired. The app recovered to static content and prepared the next surface. The fourth and fifth surfaces completed.

Surface in preparation order Duration from native preparation start Outcome
1 3,195 ms App warmup timeout
2 3,067 ms App warmup timeout
3 3,057 ms App warmup timeout
4 2,506 ms Native handoff complete
5 399 ms Native handoff complete

At all three deadlines the texture and script had reported ready, the ticker was active, deferred rendering was not paused, and the texture reported canAcceptDeferredFrame == false. Initial input loading and decoding accounted for 22–167 ms of the three timed-out attempts. Our app owns the watchdog and starts the next surface after it fires, so these durations are not native timeout values.

A Perfetto capture aligned to these same milestones sampled the render thread during the first attempt:

RiveRender
  rive_native::replayDeferredFrame
  rive::ore::ContextGL::makePipeline
  glLinkProgram (libGLES_mali.so)
  cmpbe_v2_compile_multiple_shaders (libGLES_mali.so)

glLinkProgram appears in 196 of 218 render-thread samples in that first interval. The Mali compiler thread accumulated about 8.15 seconds of CPU time across the first four preparation intervals. These are sampling and scheduling measurements, not wall-clock measurements of individual shader links. During the overall preparation sequence, the longest captured rive_native platform-message slice was 5.9 ms. Flutter continued rendering. This is separate from the synchronous texture-removal freeze fixed in #661.

Is there a supported way to prewarm a scripted GPUCanvas surface or observe when its initial deferred GPU work has completed on Android? It would help to distinguish a surface still waiting on cold pipeline linking from one that is no longer making progress. Can deferred warmup work continue asynchronously in a way that lets other surfaces already sharing the renderer get their first frames sooner?

The capture used an application asset. A minimal candidate is the neutral pipeline fixture already in #661, with one instance left mounted while it initializes and a second surface introduced while linking is in progress. That reduced fixture still needs a device run before it can be called a reproduction. Private assets and the raw device trace are kept local.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions