gfx-rs/wgpu · error

Could not lock adapter context. This is most-likely a deadlo

Error message

Could not lock adapter context. This is most-likely a deadlock.

What it means

Panic in the GLES AdapterContext::get_without_egl_lock during present: the GL context lock could not be acquired without blocking, which indicates the EGL context is current on (or held by) another thread — effectively a deadlock. The faulty input is cross-thread EGL context usage.

Source

Thrown at wgpu-hal/src/gles/egl.rs:318

}

impl AdapterContext {
    /// Get's the [`glow::Context`] without waiting for a lock
    ///
    /// # Safety
    ///
    /// This should only be called when you have manually made sure that the current thread has made
    /// the EGL context current and that no other thread also has the EGL context current.
    /// Additionally, you must manually make the EGL context **not** current after you are done with
    /// it, so that future calls to `lock()` will not fail.
    ///
    /// > **Note:** Calling this function **will** still lock the [`glow::Context`] which adds an
    /// > extra safe-guard against accidental concurrent access to the context.
    pub unsafe fn get_without_egl_lock(&self) -> MappedMutexGuard<'_, glow::Context> {
        let guard = self
            .glow
            .try_lock_for(Duration::from_secs(CONTEXT_LOCK_TIMEOUT_SECS))
            .expect("Could not lock adapter context. This is most-likely a deadlock.");
        MutexGuard::map(guard, |glow| &mut **glow)
    }

    /// Obtain a lock to the EGL context and get handle to the [`glow::Context`] that can be used to
    /// do rendering.
    #[track_caller]
    pub fn lock<'a>(&'a self) -> AdapterContextLock<'a> {
        let glow = self
            .glow
            // Don't lock forever. If it takes longer than 1 second to get the lock we've got a
            // deadlock and should panic to show where we got stuck
            .try_lock_for(Duration::from_secs(CONTEXT_LOCK_TIMEOUT_SECS))
            .expect("Could not lock adapter context. This is most-likely a deadlock.");

        let egl = self.egl.as_ref().map(|egl| {
            egl.make_current();
            EglContextLock {
                instance: &egl.instance,

View on GitHub (pinned to 3e11ff59bf)

Solutions

  1. Ensure only one thread makes the EGL context current at a time
  2. Release the EGL context (make it non-current) before other threads present
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at wgpu-hal/src/gles/egl.rs:318 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of gfx-rs/wgpu@3e11ff59bf (2026-09-03). Data as JSON: /api/errors/7bed87a9ba382c55. Report an issue: GitHub.