{"record":{"id":"dd417b394365b007","repo":"rustdesk/rustdesk","slug":"rotation-not-supported","errorCode":null,"errorMessage":"rotation not supported","messagePattern":"rotation not supported","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"libs/scrap/src/common/vram.rs","lineNumber":105,"sourceCode":"                        same_bad_len_counter: 0,\n                    }),\n                    Err(_) => Err(anyhow!(format!(\"Failed to create encoder\"))),\n                }\n            }\n            _ => Err(anyhow!(\"encoder type mismatch\")),\n        }\n    }\n\n    fn encode_to_message(\n        &mut self,\n        frame: EncodeInput,\n        ms: i64,\n    ) -> ResultType<base::message_proto::VideoFrame> {\n        let (texture, rotation) = frame.texture()?;\n        if rotation != 0 {\n            // to-do: support rotation\n            // Both the encoder and display(w,h) information need to be changed.\n            bail!(\"rotation not supported\");\n        }\n        let mut vf = VideoFrame::new();\n        let mut frames = Vec::new();\n        for frame in self\n            .encode(texture, ms)\n            .with_context(|| \"Failed to encode\")?\n        {\n            frames.push(EncodedVideoFrame {\n                data: Bytes::from(frame.data),\n                pts: frame.pts,\n                key: frame.key == 1,\n                ..Default::default()\n            });\n        }\n        if frames.len() > 0 {\n            // This kind of problem is occurred after a period of time when using AMD encoding,\n            // the encoding length is fixed at about 40, and the picture is still\n            const MIN_BAD_LEN: usize = 100;","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/rustdesk/rustdesk/blob/91c9fccbb0f7bfe5f11644d5fbdec9b23fa10540/libs/scrap/src/common/vram.rs#L87-L123","documentation":"encode_to_message extracts the captured texture plus a rotation value; if rotation != 0 it bails with `rotation not supported`. The VRAM hardware encoder path has no implementation for rotated displays — both the encoder configuration and the reported display width/height would need to change, which is still a to-do in the code. So encoding a rotated capture through the hardware path is explicitly unsupported.","triggerScenarios":"Calling encode_to_message when the frame's texture reports a non-zero rotation — i.e. capturing a display whose orientation is rotated 90/180/270 degrees on a machine using the VRAM (hardware) encoder.","commonSituations":"Remote machine has a monitor in portrait mode or rotated via display settings; user rotates a monitor mid-session and the next capture carries rotation while the VRAM encoder is active.","solutions":["Set the remote display rotation back to 0 degrees (landscape default) so the capture reports rotation == 0.","Fall back to the software capture/encoder path, which handles rotated displays, instead of the VRAM path.","Implement rotation support in vram.rs: reconfigure the encoder and swap the reported display w/h when rotation is non-zero (the code's own to-do)."],"exampleFix":"// before\nlet (texture, rotation) = frame.texture()?;\nif rotation != 0 {\n    bail!(\"rotation not supported\");\n}\n// after\nlet (texture, rotation) = frame.texture()?;\nif rotation != 0 {\n    log::warn!(\"rotated display on vram path, falling back to software encoder\");\n    return software_encoder.encode_to_message(frame, ms);\n}","handlingStrategy":"fallback","validationCode":"let (_, rotation) = frame.texture()?;\nif rotation != 0 {\n    // switch to software encoder path before calling vram encode_to_message\n}","typeGuard":"fn rotation_supported(rotation: i32) -> bool { rotation == 0 }","tryCatchPattern":"// Rust: match on Result\nmatch vram_encoder.encode_to_message(frame, ms) {\n    Ok(vf) => vf,\n    Err(e) if e.to_string() == \"rotation not supported\" => software_encoder.encode_to_message(frame, ms)?,\n    Err(e) => return Err(e),\n}","preventionTips":["Detect display rotation at session setup and pick the software encoder for rotated displays","Listen for display-change events and re-evaluate encoder choice when rotation changes","Document that the VRAM path requires rotation == 0"],"tags":["video-encoding","display-rotation","hardware-codec","rust"],"backgroundTag":"unsupported-operation","analyzedSha":"91c9fccbb0f7bfe5f11644d5fbdec9b23fa10540","analyzedAt":"2026-09-10T19:53:44.083Z","contentChangedAt":"2026-09-10T19:53:44.083Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}