{"record":{"id":"b687aaa49d87721e","repo":"rustdesk/rustdesk","slug":"not-texture-frame","errorCode":null,"errorMessage":"not texture frame","messagePattern":"not texture frame","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"libs/scrap/src/common/mod.rs","lineNumber":225,"sourceCode":"}\n\npub enum EncodeInput<'a> {\n    YUV(&'a [u8]),\n    Texture((*mut c_void, usize)),\n}\n\nimpl<'a> EncodeInput<'a> {\n    pub fn yuv(&self) -> ResultType<&'_ [u8]> {\n        match self {\n            Self::YUV(f) => Ok(f),\n            _ => bail!(\"not pixelfbuffer frame\"),\n        }\n    }\n\n    pub fn texture(&self) -> ResultType<(*mut c_void, usize)> {\n        match self {\n            Self::Texture(f) => Ok(*f),\n            _ => bail!(\"not texture frame\"),\n        }\n    }\n}\n\n#[derive(Debug, PartialEq, Eq, Clone, Copy)]\npub enum Pixfmt {\n    BGRA,\n    RGBA,\n    RGB565LE,\n    I420,\n    NV12,\n    I444,\n}\n\nimpl Pixfmt {\n    pub fn bpp(&self) -> usize {\n        match self {\n            Pixfmt::BGRA | Pixfmt::RGBA => 32,","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/rustdesk/rustdesk/blob/91c9fccbb0f7bfe5f11644d5fbdec9b23fa10540/libs/scrap/src/common/mod.rs#L207-L243","documentation":"The counterpart of [94]: `EncodeInput::texture()` (libs/scrap/src/common/mod.rs:225) only succeeds for Self::Texture and bails with `not texture frame` when the input wraps a plain YUV pixel buffer. Callers that need a GPU texture handle (ptr, size) for texture-based encoding get this error if the capture backend delivered a software YUV frame.","triggerScenarios":"Calling `.texture()` on an EncodeInput::YUV — e.g. a texture/hardware encoder fed by a capture path that returned software frames (Wayland/X11 software capture, or GPU capture disabled), so there is no texture handle to pass to the encoder.","commonSituations":"Hardware (GPU) encoding configured on a system where capture produced a CPU pixel buffer; capture backend fallback silently switching from texture to YUV output; calling the wrong accessor for the frame type.","solutions":["Check the EncodeInput variant before calling texture(); use yuv() for YUV frames and fall back to a software encoder.","Enable/verify the texture-capable capture backend (e.g. DXGI) when hardware texture encoding is required.","Handle both variants in the encode loop with a match instead of assuming one frame type."],"exampleFix":"// before\nlet (ptr, size) = input.texture()?;\ntex_encoder.encode(ptr, size)?;\n// after\nif let EncodeInput::Texture(_) = input {\n    let (ptr, size) = input.texture()?;\n    tex_encoder.encode(ptr, size)?;\n} else {\n    sw_encoder.encode(input.yuv()?, ...)?;\n}","handlingStrategy":"type-guard","validationCode":"let (ptr, size) = match &input {\n    EncodeInput::Texture(_) => input.texture()?,\n    _ => return Err(/* use yuv() path instead */),\n};","typeGuard":"fn is_texture_input(input: &EncodeInput) -> bool {\n    matches!(input, EncodeInput::Texture(_))\n}","tryCatchPattern":"match input.texture() {\n    Ok((ptr, size)) => hw_encoder.encode(ptr, size)?,\n    Err(_) => sw_encoder.encode(input.yuv()?)?,\n}","preventionTips":["Verify the capture backend actually produces GPU textures before using hardware texture encoders","Handle capture-backend fallback (texture -> YUV) in the encode loop","Never call texture()/yuv() unconditionally on EncodeInput"],"tags":["rust","screen-capture","gpu","type-mismatch"],"backgroundTag":"incompatible-source-type","analyzedSha":"91c9fccbb0f7bfe5f11644d5fbdec9b23fa10540","analyzedAt":"2026-09-10T19:53:44.083Z","contentChangedAt":"2026-09-10T19:53:44.083Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}