Skip to content

Android Input Event Latency Due to Thread Separation Between MainLooper and GUI Rendering #7875

@suqiernb

Description

@suqiernb

Description

I'm experiencing significant input latency when using egui on Android, directly related to the compatibility issue described in #7478. As noted in that issue, the SurfaceView + dispatchEvent approach has fundamental incompatibilities with egui's event processing model, leading to unavoidable latency.

Problem Analysis

  1. Thread Separation:
    • Android touch/input events are dispatched exclusively on the MainLooper (UI thread)
    • OpenGL/egui rendering must happen in a separate thread (can't block UI thread)
    • This creates an inherent thread synchronization delay
  2. Observed Symptoms:
    • Touch events feel "laggy" or "sluggish"
    • Visual feedback delayed by 1-2 frames(16~32ms / 60fps)
    • Event processing backlog during high-frequency touch events
# Simplified current flow
Android UI Thread (MainLooper) → JNI Bridge → Rust Event Queue → Rendering Thread

Root Causes

  • Mandatory Thread Separation: Android's architecture requires UI operations on MainLooper, but rendering can't block it.
  • Lack of Frame Synchronization: No coordination between event delivery and frame boundaries.

Request

We need to address the fundamental architectural issue raised in #7478

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions