Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Safari getDisplayMedia must be called from a user gesture handler

My website has the functionality to take screenshots with share screen functionality. On chrome and firefox everything works fine, but on safari i get an error "getDisplayMedia must be called from a user gesture handler". Is it possible to simulate user gesture from within the code itself? I have tried to use myButton.click(), but it doesn't register as an user gesture.

like image 893
Zagora Avatar asked Sep 05 '25 03:09

Zagora


1 Answers

It is not possible to generate a user gesture from within the code. This safari error occures due to the event (event that should trigger it) having isTrusted property false. This property is set automatically and is not possible to fake. If you do a genuine user gesture this property is true, if you invoke an event from within the code it's false. In my case I simply generated a panel with backdrop asking for confirmation to take the screenshot to invoke this action with a genuine user gesture.

like image 131
Zagora Avatar answered Sep 07 '25 23:09

Zagora