Skip to content

Offload to Dart Isolate to Prevent UI Freezing #24

@tinyjin

Description

@tinyjin

Currently, when ThorVG.flutter performs animation rendering via FFI, the main UI thread may become blocked in heavy cases, resulting in visible freezing or stuttering of the user interface.

Image
https://dart.dev/language/isolateshttps://dart.dev/language/isolates

It'd be beneficial if we could consider offloading intensive animation calculations to a Dart Isolate. This approach would allow the main thread to remain responsive, ensuring smooth UI updates regardless of the complexity of the animation logic. The Isolate would handle the heavy computation and return results to the main thread for rendering on the canvas.

Considerations

  • Data Transfer: Using SendPort/ReceivePort for heavy data passing could overhead (ex_ animation frame data)
    • Solution: Passing ffi.Pointer<FlutterLottieAnimation> rather than original buffer would not take much
  • Using multipel concurrency model: If both Dart Isolate and native threading are combined, issues like race conditions, synchronization challenges, and increased debugging complexity may arise.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions