{"record":{"id":"94ee012462f5dde1","repo":"screenpipe/screenpipe","slug":"createtexture2d-returned-no-texture","errorCode":null,"errorMessage":"CreateTexture2D returned no texture","messagePattern":"CreateTexture2D returned no texture","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/screenpipe-screen/src/wgc_capture.rs","lineNumber":329,"sourceCode":"fn create_texture_like(\n    device: &ID3D11Device,\n    src_desc: &D3D11_TEXTURE2D_DESC,\n    usage: D3D11_USAGE,\n    cpu_access_flags: u32,\n) -> Result<ID3D11Texture2D> {\n    let mut desc = *src_desc;\n    desc.Usage = usage;\n    desc.BindFlags = 0;\n    desc.CPUAccessFlags = cpu_access_flags;\n    desc.MiscFlags = 0;\n\n    let mut texture = None;\n    unsafe {\n        device\n            .CreateTexture2D(&desc, None, Some(&mut texture))\n            .map_err(|e| anyhow!(\"CreateTexture2D: {}\", e))?;\n    }\n    texture.ok_or_else(|| anyhow!(\"CreateTexture2D returned no texture\"))\n}\n\nextern \"system\" fn monitor_enum_proc(\n    h_monitor: HMONITOR,\n    _hdc: HDC,\n    _rect: *mut RECT,\n    state: LPARAM,\n) -> BOOL {\n    unsafe {\n        (*(state.0 as *mut Vec<HMONITOR>)).push(h_monitor);\n    }\n    TRUE\n}\n\n/// Resolve a live `HMONITOR` for `monitor_id` (xcap's monitor id is `HMONITOR.0 as u32`).\n/// Re-enumerating (rather than reconstructing the pointer from the id) makes sure the\n/// handle is still valid right now, matching how the rest of this crate resolves ids.\nfn find_hmonitor(monitor_id: u32) -> Result<HMONITOR> {","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/screenpipe/screenpipe/blob/4ebf712990fee17eeaf904dacf749b6e96ac9bf3/crates/screenpipe-screen/src/wgc_capture.rs#L311-L347","documentation":"This is the companion null-check for [553]: `CreateTexture2D` returned S_OK but left the output texture pointer null. Since downstream code (CopyResource, Map) cannot tolerate a null texture, `create_texture_like` converts it into an explicit error. It is a defensive invariant check that rarely fires; when it does, it points to a device/runtime anomaly.","triggerScenarios":"`device.CreateTexture2D(&desc, None, Some(&mut texture))` reports success but `texture` stays `None`, reached from `store_frame` or `readback` — e.g. under DLL hooking of d3d11.dll or a broken driver that fakes success.","commonSituations":"Same environments as [553]: hooked d3d11.dll (overlays/AV), corrupt driver installations, or exotic third-party graphics-stack shims that return success without creating the object.","solutions":["Update/clean-reinstall GPU drivers","Disable overlay/recording software that may hook d3d11.dll and retry","Run `sfc /scannow` to verify d3d11.dll integrity","Log the descriptor (size/format) that triggered it to rule out a degenerate request","Treat as fatal for the capture session and restart the WGC capture"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match create_texture_like(&device, &src_desc, staging) {\n    Err(e) if e.to_string().contains(\"returned no texture\") => {\n        // environment anomaly: restart session, flag d3d11.dll hooking\n        eprintln!(\"CreateTexture2D silently failed; restarting capture session\");\n        restart_capture_session();\n    }\n    Ok(t) => { /* use texture */ }\n    Err(e) => return Err(e),\n}","preventionTips":["Treat silent nulls as a session-level fault and restart the WGC capture","Check for DLL hooks on d3d11.dll in affected environments","Keep GPU drivers clean and current","Log the descriptor alongside the failure for reproducibility"],"tags":["windows","directx","texture","null-check","wgc"],"backgroundTag":"createtexture2d-failed","analyzedSha":"4ebf712990fee17eeaf904dacf749b6e96ac9bf3","analyzedAt":"2026-09-01T23:33:43.065Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}