fix: resolve appIcon error in desktopCapturer.getSources#49219
fix: resolve appIcon error in desktopCapturer.getSources#49219KanishkRanjan wants to merge 3 commits intoelectron:mainfrom
appIcon error in desktopCapturer.getSources#49219Conversation
|
There was a problem hiding this comment.
Thanks for adjusting the PR!
- In the PR description, it’s a good idea to link manually to the upstream patch and to the specific comment where they requested 32x32.
- One commit is still unsigned.
- Can you fix the grammar in the PR title? Example:
fix: desktopCapturer.getSources returned empty appIcon - Can you remove the issue number from the title and instead add "Fixes #{issue number}" at the beginning of the description? That will make the PR automatically close that issue when it's merged.
- Can you adjust the release notes? As far as I understand, in Electron the icon is not low-resolution at the moment, but it is empty, correct? So the PR fixes the icon being empty.
cfece9a to
86203b8
Compare
|
Hi @nikwen, Thank you for the review 😊. I have made changes according to review. Best, |
appIcon error in desktopCapturer.getSources
|
Thanks, Kanishk! I'd be fine with solving it this way. Personally, I would have done it as described in #48063 (comment) to make it easier to understand from reading the code that we overwrite the upstream macOS behavior. However, I'd be fine with either. Let's have other reviewers weigh in on this, too. Thanks for adding a test. That's appreciated! |
|
Not sure why the builds keep failing. Could you rebase on the latest |
a09fa8b to
c880480
Compare
|
@nikwen , I have rebased, PTAL. Thank you for your time. |
|
Hi @nikwen and @KanishkRanjan , was wondering if there are any updates on this fix? |
|
@fanhillary let’s wait for nikwen’s reply. You can run native code with Electron, which allows you to extract icons ( you can take inspiration from this gist ). This gives you much finer control. If you want, I can put together a simple example program. |
This is waiting for another maintainer to take a look. I reached out to some maintainers yesterday even before @fanhillary's message but haven't received a reply yet. |
Removing my stale review.
I'm good with merging this. However, I would like another reviewer to look at #49219 (comment). I'd love to get a second opinion on what's the better way to implement this. Then I'll happily approve either of the two approaches.
dsanders11
left a comment
There was a problem hiding this comment.
My two cents, I think the one-line patch described by @nikwen here would be the lesser of two evils. Other maintainers may disagree.
I know our patch policy says to avoid indefinite-lifetime patches, but for a one liner I think the trade off is worth avoiding the code copy, especially since this PR is adding a test case.
Copying code from upstream inherently causes divergence over time, and over time that means we miss out on bug fixes or improvements upstream since we've copied old code and have no forcing mechanism to notice the copied code has changed upstream.
|
Thank you for your review. 😊 I think in future users might request for a feature to control image icon resolution so for that case we might require our own solution. what do you think @dsanders11 ? |
nikwen
left a comment
There was a problem hiding this comment.
Thanks for the update!
You previously had a test for the icon size. Can we add that back?
patches/chromium/fix_add_support_for_skipping_first_2_no-op_refreshes_in_thumb_cap.patch
Show resolved
Hide resolved
patches/chromium/fix_add_support_for_skipping_first_2_no-op_refreshes_in_thumb_cap.patch
Outdated
Show resolved
Hide resolved
5a70d7b to
c78144f
Compare
nikwen
left a comment
There was a problem hiding this comment.
Thanks for adding back tests!
Unfortunately, the Chromium patch changed beyond what we had discussed. The goal was to keep it merged into the patch that it was merged into and only change the comments in that patch file.
Could you please undo the patch changes to the previous revision you pushed and only make the comment changes that were requested?
Thanks!
769fa1e to
f7a0324
Compare
f7a0324 to
2f261a1
Compare
|
@KanishkRanjan can you rebase to fix the CI error on the lint job? |
|
@jkleinsc Thank you for suggestion; I have ran the comman |
nikwen
left a comment
There was a problem hiding this comment.
I don't think the PR has been rebased.
|
@nikwen I strongly believe that it is rebased but I could be wrong. Please suggestion be step or how to verify this ? Thank you. |
|
@KanishkRanjan this does not look to be properly rebased. Try the following on your fork:
OR If for some reason git remote -v shows electron/electron with another name use that. If it isn't listed at all, add it first:
|
29c4f83 to
856c02f
Compare
856c02f to
71881cc
Compare
|
Thank you @jkleinsc, I have rebased it to main; my remote org was outdated, I have synced it. |
|
Looking at the test output, it seems like Windows does indeed return 32x32px icons (as discussed in #49219 (comment)). In that case, I don't see why we should return higher-resolution icons on macOS. The trade-off of floating a Chromium patch doesn't seem worth it. However, what we might want to do then is backport https://crrev.com/c/7239386 to Electron 40 so that people like @fanhillary can get their icons back in a stable release. @KanishkRanjan Would you be willing to do that? |
|
on it. |
Backports the fix for high-resolution icons on macOS from Chromium. Chromium CL: https://chromium-review.googlesource.com/c/chromium/src/+/7239386 Backport of electron#49219
Backports the fix for high-resolution icons on macOS from Chromium. Chromium CL: https://chromium-review.googlesource.com/c/chromium/src/+/7239386 Backport of electron#49219
|
@fanhillary please take a look above. |
Description of Change
Fixes #48063
This issue was fixed via a patch in Chromium. However, during review, it was requested that the icon size be set to 32×32 instead of 128×128.
The Problem: The upstream Chromium implementation
window_icon_util_mac.mmcaptures NSImage icons at their default logical size of {32, 32}. When converted togfx::ImageSkia, only the 1x (32px) and 2x (64px) representations are preserved, discarding the high-resolution assets present in the source file.The Fix: Created a local copy of the window icon utility logic (derived from window_icon_util_mac.mm) that explicitly enforces a target size of 128x128 to capture high-DPI assets. Modified electron_api_desktop_capturer to call this custom implementation instead of the upstream Chromium function, ensuring Electron receives sharp icons without altering upstream files.
Test Plan: Verified manually with a sample Electron app.
Before and After patch comparison
Before:

After:

Checklist
npm testpassesRelease Notes
Notes: Fixed an issue where window icons returned by desktopCapturer on macOS were low resolution.