3

Is there a message that could be sent in a way that at least Safari, if not other browsers, understands that tells Mavericks not to engage App Nap? I have an HTML5 pseudo-MIDI rendering app (i.e., sends individual notes out as mp3 audio) which plays back fine on Safari so long as it's in the foreground, but when focus is lost Safari/OS X does not send back sufficient calling information to play the notes at their appropriate times. What I'd love is something like:

if (window.disallowAppNap !== undefined) {
    window.disallowAppNap = true;
}
this.playScore(callbacks = {end: function() { 
        if (window.disallowAppNap !== undefined) {
           window.disallowAppNap = false;
        }
    } }
);

From a web search, it seems that the answer to this is "Nope," but maybe someone on the OS X or Safari dev. team will see this and think, "that's a great idea!" I've looked through the Web Audio API but can't see anything connecting to App Nap.

  • 1
    I know I'm a little late on this one, but maybe nowadays Electron would be the way to go. – Kyle Hotchkiss Jan 1 '18 at 22:36
  • Ah! you're probably referring to electronjs.org/docs/api/… -- it's a bit too late for my app to rebuild on electron, but i'll see if there is a way to use their code. – Michael Scott Cuthbert Mar 26 '18 at 19:19
  • oh, this is for desktop apps, I'm looking for a javascript solution. – Michael Scott Cuthbert Mar 26 '18 at 19:22
3

Nope, not currently. JavaScript/HTML can't directly control App Nap in Safari or any other browser on OS X.

  • thanks. Given your reputation, I'm tempted to mark this as Accepted immediately, but I'll give it a day to see if someone's come up with a clever trick. If I haven't marked it by then, please feel free to prod me. – Michael Scott Cuthbert Jun 4 '14 at 14:58
  • @michael Haha, it's not like I'm in need of reputation :) Feel free to leave this unaccepted until an actual answer comes up in the future – grg Jun 4 '14 at 15:01
  • 1
    till then, my thanks. I think that sending a continuous <audio> signal at the minimum possible volume is helping, but it's a bad way of coping. – Michael Scott Cuthbert Jun 4 '14 at 15:57
  • 1
    @MichaelScottCuthbert, yes, audio element works for me, it prevents going Firefox to go to App Nap even if audio is muted but it takes some additional CPU usage. Sort of compromise... So I have used some 1sec mp3 in loop with very low bitrate. – walv Nov 19 '14 at 9:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .