Back Midas Rome Roody Rootana
  Midas DAQ System  Not logged in ELOG logo
Entry  28 Nov 2019, Konstantin Olchanski, Bug Report, midas alarm sound unreliable in google-chrome 
    Reply  28 Nov 2019, Stefan Ritt, Bug Report, midas alarm sound unreliable in google-chrome beep.mp3
Message ID: 1742     Entry time: 28 Nov 2019     Reply to this: 1743
Author: Konstantin Olchanski 
Topic: Bug Report 
Subject: midas alarm sound unreliable in google-chrome 
I accidentally discovered a problem with the alarm sounds played by midas.

The javascript code is very simple: var audio=new Audio("alarm.mp3");;

In the past, this reliably played a sound.

More recently, I started seeing javascript log messages about "unhandled exception" from (for me, they often
interrupt my javascript debugger sessions, in a very annoying way).

Adding an exception handler to was not effective: it turns out, these days, returns a Promise
and one must handle the Promise rejection case. (also it turns out that in the rejection handler
one *must* clear audio.src to avoid problems with excessive memory and cpu use).

But why does throw a rejected promise?!?

This is the error message provided: "play() failed because the user didn't interact with the document first."
name: "NotAllowedError".

The link takes us to This web page seems to explain
everything neatly, but most of the information turns out to be wrong and unhelpful:

a) "Muted autoplay is always allowed" - wrong - I see rejection from muted tabs
b) "User has interacted with the domain (click, tap, etc.)." - wrong - I see rejection in the javascript debugger even as I debug the web page
c) "user's Media Engagement Index threshold has been crossed" - broken - playback count and MEI is always 0 (zero) for midas - per chrome://media-engagement/
d) "user has added the site to their home screen on mobile or installed the PWA on desktop" - what ?!?
e) chrome://flags/#autoplay-policy does not exist (was removed)

There may be a way to start google-chrome with special flags to globally enable autoplay, but it seems
to be aimed at "kiosk" type applications, not for general use browsers:

The bottom line:

there is no way to ensure that the alarm sound will always play


P.S. I am tracking this problem here:
ELOG V3.1.4-2e1708b5