A user gesture handler refers to something like this
startButton.addEventListener('click', (e) => {
whatever.getDisplayMedia(...);
});
Examples of calling it not from such a handler would be:
- calling it from the top level of the script
- calling it from an onload callback
- calling it in the callback of a
setTimeout
These latter cases result in some unpleasant behavior of a bunch of permission popups appearing as the page loads. Browsers have since put in place these rules to prevent that. You’ll have to restructure your program to wait for the user to click a button or something similar–a ‘gesture,’ as the error message dictates.