-
-
Notifications
You must be signed in to change notification settings - Fork 443
Bookmark plugin - catch an exception for empty / broken favicons #3973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Catch an exception for empty / corrupted favicons.
🥷 Code experts: Jack251970, jjw24 Jack251970, jjw24 have most 👩💻 activity in the files. See details
Activity based on git-commit:
Knowledge based on git-blame: ✨ Comment |
Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX. |
📝 WalkthroughWalkthroughRefactors FaviconHelper.TryConvertToWebp to use using var disposals, adds a null-check after creating an SKImage from a bitmap, retains WebP encoding at quality 65, returns encoded bytes on success or null otherwise, and preserves bitmap disposal in finally. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal). Please share your feedback with us on this Discord post. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
Plugins/Flow.Launcher.Plugin.BrowserBookmark/Helper/FaviconHelper.cs (2)
79-92
: Dispose SKSvg and avoid 0x0 bitmap creation for empty SVGsThis prevents a small leak and avoids constructing invalid SKBitmaps when the SVG cull rect is empty.
- using (var ms = new MemoryStream(data)) - { - var svg = new SKSvg(); - if (svg.Load(ms) != null && svg.Picture != null) - { - bitmap = new SKBitmap((int)svg.Picture.CullRect.Width, (int)svg.Picture.CullRect.Height); - using (var canvas = new SKCanvas(bitmap)) - { - canvas.Clear(SKColors.Transparent); - canvas.DrawPicture(svg.Picture); - canvas.Flush(); - } - } - } + using (var ms = new MemoryStream(data)) + { + using var svg = new SKSvg(); + if (svg.Load(ms) != null && svg.Picture != null) + { + var cull = svg.Picture.CullRect; + var w = (int)Math.Ceiling(cull.Width); + var h = (int)Math.Ceiling(cull.Height); + if (w > 0 && h > 0) + { + bitmap = new SKBitmap(w, h); + using var canvas = new SKCanvas(bitmap); + canvas.Clear(SKColors.Transparent); + canvas.DrawPicture(svg.Picture); + } + } + }
60-67
: Pre-create the output directory to avoid DirectoryNotFoundExceptionMinor robustness tweak before writing bytes.
try { + var dir = Path.GetDirectoryName(outputPath); + if (!string.IsNullOrEmpty(dir)) + Directory.CreateDirectory(dir); File.WriteAllBytes(outputPath, imageData); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
Plugins/Flow.Launcher.Plugin.BrowserBookmark/Helper/FaviconHelper.cs
(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: Jack251970
PR: Flow-Launcher/Flow.Launcher#3897
File: Flow.Launcher/ViewModel/PluginViewModel.cs:46-51
Timestamp: 2025-08-13T06:12:43.382Z
Learning: In Flow Launcher's PluginViewModel.cs, the LoadIconAsync method does not require additional try-catch error handling according to maintainer Jack251970, as the existing error handling approach is considered sufficient for the image loading operations.
📚 Learning: 2025-08-13T06:12:43.382Z
Learnt from: Jack251970
PR: Flow-Launcher/Flow.Launcher#3897
File: Flow.Launcher/ViewModel/PluginViewModel.cs:46-51
Timestamp: 2025-08-13T06:12:43.382Z
Learning: In Flow Launcher's PluginViewModel.cs, the LoadIconAsync method does not require additional try-catch error handling according to maintainer Jack251970, as the existing error handling approach is considered sufficient for the image loading operations.
Applied to files:
Plugins/Flow.Launcher.Plugin.BrowserBookmark/Helper/FaviconHelper.cs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: gitStream.cm
- GitHub Check: build
Plugins/Flow.Launcher.Plugin.BrowserBookmark/Helper/FaviconHelper.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Bookmark plugin - catch an exception for empty / broken favicons
Catch an exception for empty / corrupted favicons.
This is just a quick fix until I complete a rewrite of this plugin which will properly fix this issue.