Skip to content
This repository was archived by the owner on Jul 11, 2026. It is now read-only.

fix(runtime): resolve main thread freeze and stabilize cross-platform initialization - #5

Open
spiccoaura wants to merge 1 commit into
google:mainfrom
spiccoaura:main
Open

spiccoaura wants to merge 1 commit into
google:mainfrom
spiccoaura:main

Conversation

@spiccoaura

Copy link
Copy Markdown

Description

This pull request addresses two critical issues reported by the community regarding runtime execution and platform stability:

  1. Unity Main Thread Freeze (Issue Freezed and forced shutdown #4): Refactored synchronous native C++ P/Invoke invocations by exposing decoupled asynchronous execution wrappers using UniTask. Inference tasks (Generate and GenerateMultimodal) are now safely offloaded to the non-blocking ThreadPool, eliminating UI starvation and application crashes during heavy token processing cycles.
  2. Initialization Failures (Issue Initialisation error #1 & Initialize Gemma Error #3): Removed the rigid Win32 LoadLibrary bottleneck from the static constructor context. Replaced it with an explicit dynamic platform architecture guard using RuntimeInformation.IsOSPlatform(OSPlatform.Windows). This stabilizes cross-platform compilation and deployment fallbacks on alternative operating environments (e.g., Android/Linux).

Impact

  • Seamless asynchronous per-token UI update updates via managed main-thread loops synchronization handlers.
  • Full unmanaged non-blocking multimodal analysis support integration for PaliGemma sequences.
  • Prevents immediate startup sequence crash faults outside pure Windows desktop layouts.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant