{"record":{"id":"7bed87a9ba382c55","repo":"gfx-rs/wgpu","slug":"could-not-lock-adapter-context-this-is-most-likel","errorCode":null,"errorMessage":"Could not lock adapter context. This is most-likely a deadlock.","messagePattern":"Could not lock adapter context\\. This is most-likely a deadlock\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"wgpu-hal/src/gles/egl.rs","lineNumber":318,"sourceCode":"}\n\nimpl AdapterContext {\n    /// Get's the [`glow::Context`] without waiting for a lock\n    ///\n    /// # Safety\n    ///\n    /// This should only be called when you have manually made sure that the current thread has made\n    /// the EGL context current and that no other thread also has the EGL context current.\n    /// Additionally, you must manually make the EGL context **not** current after you are done with\n    /// it, so that future calls to `lock()` will not fail.\n    ///\n    /// > **Note:** Calling this function **will** still lock the [`glow::Context`] which adds an\n    /// > extra safe-guard against accidental concurrent access to the context.\n    pub unsafe fn get_without_egl_lock(&self) -> MappedMutexGuard<'_, glow::Context> {\n        let guard = self\n            .glow\n            .try_lock_for(Duration::from_secs(CONTEXT_LOCK_TIMEOUT_SECS))\n            .expect(\"Could not lock adapter context. This is most-likely a deadlock.\");\n        MutexGuard::map(guard, |glow| &mut **glow)\n    }\n\n    /// Obtain a lock to the EGL context and get handle to the [`glow::Context`] that can be used to\n    /// do rendering.\n    #[track_caller]\n    pub fn lock<'a>(&'a self) -> AdapterContextLock<'a> {\n        let glow = self\n            .glow\n            // Don't lock forever. If it takes longer than 1 second to get the lock we've got a\n            // deadlock and should panic to show where we got stuck\n            .try_lock_for(Duration::from_secs(CONTEXT_LOCK_TIMEOUT_SECS))\n            .expect(\"Could not lock adapter context. This is most-likely a deadlock.\");\n\n        let egl = self.egl.as_ref().map(|egl| {\n            egl.make_current();\n            EglContextLock {\n                instance: &egl.instance,","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/gfx-rs/wgpu/blob/3e11ff59bf3f9795d285ecc045014089640d7248/wgpu-hal/src/gles/egl.rs#L300-L336","documentation":"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.","triggerScenarios":"Thrown at wgpu-hal/src/gles/egl.rs:318 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure only one thread makes the EGL context current at a time","Release the EGL context (make it non-current) before other threads present"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3e11ff59bf3f9795d285ecc045014089640d7248","analyzedAt":"2026-09-03T01:43:21.459Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}