nwjs / nw.js

Call all Node.js modules directly from DOM/WebWorker and enable a new way of writing applications with all Web technologies.
https://nwjs.io
MIT License
40.32k stars 3.89k forks source link

window.navigator.webkitGetUserMedia taking too much time to respond in nwjs 0.59.2 #7917

Closed rakesh-anchan closed 2 years ago

rakesh-anchan commented 2 years ago

Thanks for reporting an issue! Spend 60 seconds reading this...

  1. Before reporting, try reproducing against the latest version of NWJS.
  2. Issue tracker is only for bugs and feature requests, in English only.

    Anything else? Use our mailing list for questions: https://groups.google.com/forum/#!forum/nwjs-general

======== TEMPLATE BUG FORM ========

NWJS Version : v0.59.2 Operating System : Windows10

Expected behavior

webkitGetUserMedia should not take more than , 300ms

Actual behavior

window.navigator.webkitGetUserMedia taking too much time to respond in nwjs 0.59.2 intermittently. We have noticed delay of 10- 15 minutes in getting streams

Note: This was working fine in v0.45.7

How to reproduce

ayushmanchhabra commented 2 years ago

Thanks for opening the issue in the chromium bug tracker. Linking this here for better visibility: https://bugs.chromium.org/p/chromium/issues/detail?id=1343275&q=webkitGetUserMedia&can=2

ayushmanchhabra commented 2 years ago

@rakesh-anchan I used v0.66.1 and consistently got less than 300ms.

Steps to reproduce:

  1. If you don't have Node installed, use volta or nvm
  2. On Node v16.16.0, launch this demo app by executing npm start
  3. Right click and choose Inspect background page to open DevTools
  4. Run the above mentioned code snippet in the Console
image
rakesh-anchan commented 2 years ago

@ayushmxn With our further analysis on the issue, we found that, api takes more time, if the nodewebkit main window is in minimized state.

When we move the window to foreground, we get the response.

ayushmanchhabra commented 2 years ago

~That's weird! Is it possible to make a small repro so I can dig into this? Seems NW.js related.~

Try making the API call from the Node context if you haven't already.

rakesh-anchan commented 2 years ago

test

I have attached video of reproducing the issue win v0.66.0 version

ayushmanchhabra commented 2 years ago

Thanks! I was able to reproduce on my end. Looks like the behaviour of getUserMedia was recently changed. I believe a workaround would be to use the Node context. As you see here, there is no issue when I run the code snippet in the background page (Node context).

ayushmanchhabra commented 2 years ago

@rakesh-anchan were you able to find a workaround?

rakesh-anchan commented 2 years ago

@ayushmxn No, we could not get the workaround and ticket (https://bugs.chromium.org/p/chromium/issues/detail?id=1343275&q=webkitGetUserMedia&can=2) which we raised in chromium site, says that, it is behavioral change done on chromium to meet the media feature compliance.

As of now we had to change the behavior in our application, whenre application was brought to focus before calling webkitgetusermedia api.

fippo commented 2 years ago

Have you tried adding the blink-features option to the command line args? It is a allowlisted flag here and the process is documented here

ayushmanchhabra commented 2 years ago

@rakesh-anchan I'll be afk till Monday if you want to give this a go. This looks promising given this comment on the Chromium ticket.

ayushmanchhabra commented 2 years ago

I get a DOMException: Requested device not found error on adding the disable blink feature flag so unable to confirm if it works.

ayushmanchhabra commented 1 year ago

@rakesh-anchan upstream ticket comment 16 may help

MistakingManx commented 1 year ago

I am experiencing this issue, my solution since it's for Windows only, was to use "nircmd" to focus the window when it needs to listen, nir win activate process nw.exe.

Is there a better method, though?