Skip to content

fix: use common Flutter render pipeline on Linux - #254

Closed
local-sandbox-agent[bot] wants to merge 3 commits into
developfrom
asb/fix-flutter-synced-frame-hook
Closed

fix: use common Flutter render pipeline on Linux#254
local-sandbox-agent[bot] wants to merge 3 commits into
developfrom
asb/fix-flutter-synced-frame-hook

Conversation

@local-sandbox-agent

@local-sandbox-agent local-sandbox-agent Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Problem

Linux takes its frame timing from Flutter's SchedulerBinding, but the Flutter-synchronized path also bypassed the normal Dart render callback and rendered directly in native code. That meant FilamentApp.render() did not run, so Dart request-frame hooks such as camera controllers and procedural updates were skipped.

The separate native render path was not required by Flutter or Filament; only the Linux frame source and external-texture notification need to be platform-specific.

Structure

FrameScheduler continues to own frame timing for every native platform:

  • direct native timing ticks
  • debug receive-port ticks
  • Flutter-synchronized Linux ticks

All three modes now dispatch the same Dart frame handler. On Linux, Flutter's persistent frame callback applies the target-FPS deadline and the common in-flight guard, then dispatches the same _renderFrame() handler as the native display-link modes.

That common callback:

  1. runs Dart request-frame hooks through FilamentApp.render()
  2. queues and awaits rendering on Thermion's render thread
  3. publishes the completed frame to Flutter

Linux keeps one presentation-specific optimization: after the common render future completes, a direct FFI call marks all registered Linux external textures available. Texture notification remains separate from scheduling and rendering.

The hooks-only callback and the separate native Linux render path have been removed. Non-Linux scheduling behavior is unchanged.

The native FrameScheduler API is now timing-only. Its C++ and C interfaces use tick terminology, and the C entry point is explicitly named FrameScheduler_startWithCallback. The unused rendering API and its global render state were deleted:

  • FrameScheduler_setRenderThread
  • FrameScheduler_setRenderManager
  • FrameScheduler_setPostRenderCallback
  • FrameScheduler_requestRender
  • FrameScheduler_startNativeRenderLoop

Dart now distinguishes incoming platform ticks from dispatched frame handlers (setFrameHandler, _tryDispatchFrame, and dispatchedFrameCount).

Validation

  • flutter analyze in thermion_flutter: no issues
  • full thermion_flutter test suite: 29 tests passed
  • focused Flutter-synchronized scheduler test covers target-FPS gating, slow-render backpressure, pause/resume, stop, and persistent-callback reuse across restart
  • quickstart analysis and web build: passed
  • native code compiled through the Flutter test harness
  • git diff --check: passed

@local-sandbox-agent
local-sandbox-agent Bot force-pushed the asb/fix-flutter-synced-frame-hook branch from ee1e5fd to d154a4f Compare August 20, 2026 00:55
@nmfisher
nmfisher force-pushed the asb/fix-flutter-synced-frame-hook branch 2 times, most recently from 9e85c4c to cf87074 Compare August 20, 2026 05:05
@nmfisher nmfisher changed the title fix: run Dart per-frame hook in flutter-synced mode fix: run Dart frame hooks in Flutter-driven Linux rendering Aug 20, 2026
@nmfisher
nmfisher force-pushed the asb/fix-flutter-synced-frame-hook branch from cf87074 to cdf81ef Compare August 20, 2026 05:14
@nmfisher
nmfisher force-pushed the asb/fix-flutter-synced-frame-hook branch from e538a0c to 4b8b211 Compare August 22, 2026 10:20
Run Dart request-frame hooks for native-admitted Linux frames while keeping Flutter-synchronized timing, admission, pause/resume, and persistent callback ownership inside FrameScheduler. Gate native requests while a Dart callback is in flight and reuse the persistent callback across restarts.
@nmfisher
nmfisher force-pushed the asb/fix-flutter-synced-frame-hook branch from 4b8b211 to f06372c Compare August 23, 2026 04:25
@nmfisher nmfisher changed the title fix: run Dart frame hooks in Flutter-driven Linux rendering fix: run Linux Dart frame hooks through FrameScheduler Aug 23, 2026
@nmfisher nmfisher changed the title fix: run Linux Dart frame hooks through FrameScheduler fix: use common Flutter render pipeline on Linux Aug 23, 2026
@nmfisher

Copy link
Copy Markdown
Owner

Closing this sandbox-app-authored PR so it can be replaced by an equivalent PR authored directly by @nmfisher. The branch and commits are unchanged.

@nmfisher nmfisher closed this Aug 23, 2026
@nmfisher

Copy link
Copy Markdown
Owner

Superseded by #278, opened directly by @nmfisher from the same branch and commits with an updated description.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant