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
refactor: eliminate DecrementCapturerCount
patch
#35710
Conversation
DecrementCapturerCount
patch
What is the necessity to allow for multiple increment capture count calls during the lifetime of a capture session ? When the API was exposed #21679 it didn't showcase an example that required multiple calls to the increment API. Also chromium's contract for the API https://source.chromium.org/chromium/chromium/src/+/main:content/public/browser/web_contents.h;l=627-661; states
With that being the case, wouldn't the following suffice
capture_handle_ = web_contents()->IncrementCapturerCount(size, stay_hidden, stay_awake);
My current concern is that callers of the Electron API are responsible to balance out the increment/decrement calls and if they don't, webContents will end up with a weird visibility state. Instead of relying on users to understand the inner details of the chromium API, we could perform the balancing automatically with only a single increment capturer count for a capture session. This would allow us to remove both the |
@deepak1556 you're right imo - i was mostly keying off comments in the previous PR to restore this behavior. I'd also personally prefer to only maintain one at any given time and store it as such. I'll update the PR. |
I like the idea that increment + decrement is done internally when the promise is created + settled. It feels like having this in public API is a footgun with no real advantage? What would you all think if we:
|
@ckerr i'm good with that! i agree it opens up more avenues for potential issues than anything else. However, i do think users would potentially want to control values of |
Just brainstorming here so feel free to push back, but maybe Is there any use case for |
@ckerr ooh good idea!! I pushed the decrement removal/deprecation - @deepak1556 thoughts on removing |
I like the idea to unify |
829ba8a
to
af8a66f
Compare
c843e1e
to
af8a66f
Compare
af8a66f
to
154975b
Compare
cfbb817
to
cb1f2dc
Compare
nice, very glad to have these methods go away. |
df767c5
to
00cde4e
Compare
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.
API LGTM
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.
can we have a test for stayhidden/stayawake?
@nornagon i can try but |
00cde4e
to
249e896
Compare
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.
API LGTM
Alright well for some reason cation is struggling here but merging given two API LGTMs and all concerns addressed. |
No Release Notes |
Description of Change
Refactors
webContents.{increment|decrement}CapturerCount
to remove usage of privateWebContents::DecrementCapturerCount
exposed via patch. We now store the handle received from calls toIncrementCapturerCount
andapi::WebContents::DecrementCaptureCount
now callsRunAndReset
on the stored capture handle.Functionality previously exposed through
webContents.{increment|decrement}CapturerCount
has now been folded intowebContents.capturePage
.Checklist
npm test
passesRelease Notes
Notes: none.