Fix regression where Vello doesn't render new document opened after closing all documents#3849
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical rendering regression where Vello failed to display newly opened documents after all previous documents had been closed. The fix ensures that the canvas cache is properly cleared upon activating a new document, preventing stale rendering data from being used and guaranteeing a fresh visual state for the user. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
The pull request effectively addresses the regression where Vello failed to render new documents after closing all previous ones. The addition of clear_canvas_cache() in NodeGraphExecutor and its invocation within PortfolioMessageHandler::SelectDocument correctly ensures that the rendering state is reset, allowing for proper rendering of newly opened documents. The changes are well-encapsulated and directly target the identified issue, improving the stability of the application's rendering pipeline.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request fixes a rendering regression with Vello when opening a new document after all others are closed. The changes involve removing a caching mechanism for SVG canvas frames on the backend, which was likely causing stale data to be used. On the frontend, a guard has been added to prevent unnecessarily replacing an already-mounted viewport canvas. My review includes a suggestion to improve the maintainability of SVG string construction in the backend.
| let matrix = format_transform_matrix(frame.transform); | ||
| let transform = if matrix.is_empty() { String::new() } else { format!(" transform=\"{matrix}\"") }; | ||
| let svg = format!( | ||
| r#"<svg><foreignObject width="{}" height="{}"{transform}><div data-canvas-placeholder="{}" data-is-viewport="true"></div></foreignObject></svg>"#, | ||
| frame.resolution.x, frame.resolution.y, frame.surface_id.0, | ||
| ); |
There was a problem hiding this comment.
The current method of constructing the transform attribute by including a leading space in the string is a bit fragile. If the space is accidentally removed during future refactoring, it would result in invalid SVG. A more explicit approach using an if/else block to construct the SVG string with or without the transform attribute would be more robust and easier to maintain.
let matrix = format_transform_matrix(frame.transform);
let svg = if matrix.is_empty() {
format!(
r#"<svg><foreignObject width="{}" height="{}"><div data-canvas-placeholder="{}" data-is-viewport="true"></div></foreignObject></svg>"#,
frame.resolution.x, frame.resolution.y, frame.surface_id.0
)
} else {
format!(
r#"<svg><foreignObject width="{}" height="{}" transform="{}"><div data-canvas-placeholder="{}" data-is-viewport="true"></div></foreignObject></svg>"#,
frame.resolution.x, frame.resolution.y, matrix, frame.surface_id.0
)
};
Fixes #3817, a regression introduced in #3722.