Skip to content

Add async rendering scheduling support in RenderContentBaseSystem and refactor RenderTextSystem to use it #318

@yorkie

Description

@yorkie

Background

Currently, rendering text and generating SDF textures in RenderTextSystem can block the main rendering loop, causing frame drops or UI stalls when large or complex text needs to be processed. To address this, we should enable asynchronous rendering for heavy operations in text rendering, allowing the page to remain responsive while resource-intensive work is performed in parallel.

Proposal

  • In src/client/builtin_scene/web_content, extend RenderContentBaseSystem to provide an async rendering scheduling method (tentative name: scheduleSurfaceUpdate).
    • This method should be designed for use by subclasses such as RenderTextSystem.
    • It should allow expensive operations (e.g., text layout, SDF texture generation) to be executed asynchronously, for example, on a separate worker/thread.
    • The method name is flexible—please choose a name that fits the codebase and architecture standards.
  • In RenderTextSystem::render(), refactor the logic such that text rendering and SDF texture generation are scheduled through the new async method and run off the main thread.
    • When the async operation completes, the content's surface dirty state should be updated in a thread-safe way.
    • This enables UpdateTextureSystem to update the texture and upload to the GPU only after async rendering is finished.

Requirements

  • The async scheduling method should be generic enough for other async rendering cases beyond text.
  • Ensure thread safety, especially when updating the content's surface dirty state and any shared resources.
  • Clearly document the API and any thread-safety guarantees.

Acceptance Criteria

  • There is an async scheduling method in RenderContentBaseSystem for offloading heavy rendering work.
  • RenderTextSystem uses the async method for text rendering and SDF generation.
  • The content's surface dirty state is updated in a thread-safe manner after async work completes.
  • UpdateTextureSystem only uploads the texture after async rendering is finished.
  • All logic is well-documented and tested for race conditions or deadlocks.

Notes

  • The method name scheduleSurfaceUpdate is a placeholder—choose a name suitable for your implementation.
  • Take extra care with thread safety when updating shared state.
  • This refactor should make text rendering non-blocking for the main render thread, improving overall frame time and responsiveness.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions