feat: disable fetching thumbnails if thumbnailSize is 0 (#14906)
Capturing window thmubnails is expensive as it actually uses the window capturer and it records one full frame per window and then downscale to the default size 150x150. When only interested in the window names or the app icons we do not need all of this. Underlying change is merged in chromium72 so this patch only modifies the doc, see: https://chromium.googlesource.com/chromium/src.git/+log/72.0.3626.52/chrome/browser/media/webrtc/native_desktop_media_list.cc Example: desktopCapturer.getSources({thumbnailSize: {width: 0, height: 0}}, ...) Also added a unit test in spec/api-desktop-capturer-spec.js that verifies that the returned thumbails are of type NativeImage and empty, when the user disable fetching thumbnails. notes: Can disable fetching the thumbnails for the DesktopCapturer. https://github.com/electron/electron/issues/14872
This commit is contained in:
parent
3dfef4a376
commit
9b29befdc8
2 changed files with 23 additions and 2 deletions
|
@ -4,6 +4,7 @@ const chaiAsPromised = require('chai-as-promised')
|
|||
const { desktopCapturer, ipcRenderer, remote } = require('electron')
|
||||
const { screen } = remote
|
||||
const features = process.atomBinding('features')
|
||||
const { emittedOnce } = require('./events-helpers')
|
||||
|
||||
const { expect } = chai
|
||||
chai.use(dirtyChai)
|
||||
|
@ -105,4 +106,20 @@ describe('desktopCapturer', () => {
|
|||
expect(sources).to.be.empty()
|
||||
})
|
||||
})
|
||||
|
||||
it('disabling thumbnail should return empty images', async () => {
|
||||
const { BrowserWindow } = remote
|
||||
const w = new BrowserWindow({ show: false, width: 200, height: 200 })
|
||||
const wShown = emittedOnce(w, 'show')
|
||||
w.show()
|
||||
await wShown
|
||||
|
||||
const sources = await desktopCapturer.getSources({ types: ['window', 'screen'], thumbnailSize: { width: 0, height: 0 } })
|
||||
w.destroy()
|
||||
expect(sources).to.be.an('array').that.is.not.empty()
|
||||
for (const { thumbnail: thumbnailImage } of sources) {
|
||||
expect(thumbnailImage).to.be.a('NativeImage')
|
||||
expect(thumbnailImage.isEmpty()).to.be.true()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue