Alarm stops firing after Macbook wakes up from deep sleep

90 views
Skip to first unread message

John Doe

unread,
Nov 13, 2023, 12:59:11 PM11/13/23
to Chromium Extensions
I have an extension with an alarm which is fired every minute. I initialize the alarm (alarms.create()) in runtime.onInstalled.addListener.

The problem is that this alarm stops being fired after my macbook returns from deep sleep  (~6-10 hours).

Am I misunderstanding the docs and the fix is to create alarm on runtime.onStartup event or is it a bug?

Thanks in advance!

Oliver Dunk

unread,
Nov 13, 2023, 1:16:33 PM11/13/23
to John Doe, Chromium Extensions
Hi John,

There's definitely some interesting alarm behaviour at the moment. You can see some links and some work in progress documentation on that here: https://github.com/GoogleChrome/developer.chrome.com/pull/7776

That said, I'm not aware of any situation where an alarm should be lost from sleep assuming the browser stays open throughout. Is the alarm still present, for example if you do `chrome.alarms.get`?
Oliver Dunk | DevRel, Chrome Extensions | https://developer.chrome.com/ | London, GB


--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/ca45b301-c913-4a32-b15f-8313c888cb03n%40chromium.org.

John Doe

unread,
Nov 13, 2023, 1:21:59 PM11/13/23
to Chromium Extensions, Oliver Dunk, Chromium Extensions, John Doe
Hi Oliver, thanks for replying!

chrome.alarms.getAll(console.log) gives an empty array.
Chrome was opened during sleep, however even after restarting the chrome after waking up the alarm is not fired.

Would you suggest to add additional check for alarms and creating an alarm in case there are none on runtime.onStartup in the meantime to fix the issue?

Oliver Dunk

unread,
Nov 13, 2023, 1:27:39 PM11/13/23
to John Doe, Chromium Extensions
Unfortunately runtime.onStartup is only fired when a profile is opened, so it wouldn't fire when a device wakes from sleep.

You might be able to use the `chrome.idle` API as a workaround here, and check for alarms when the state changes: https://developer.chrome.com/docs/extensions/reference/idle/

If you can consistently reproduce, some steps in a Chrome bug would definitely be appreciated. I haven't heard of this issue before.

Oliver Dunk | DevRel, Chrome Extensions | https://developer.chrome.com/ | London, GB

Pavel Aronovich

unread,
Nov 14, 2023, 2:32:40 AM11/14/23
to Chromium Extensions, Oliver Dunk, Chromium Extensions, John Doe
I solved the alarm problem by checking with get() when starting SW.
If it's not there, then I create it again.

понедельник, 13 ноября 2023 г. в 21:27:39 UTC+3, Oliver Dunk:

John Doe

unread,
Nov 14, 2023, 4:24:17 AM11/14/23
to Chromium Extensions, Pavel Aronovich, Oliver Dunk, Chromium Extensions, John Doe
Hi Pavel, thanks for your suggestion!

Could you please clarify, when you say when starting SW - what event listener is that exactly? 

John Doe

unread,
Nov 14, 2023, 4:50:05 AM11/14/23
to Chromium Extensions, John Doe, Oliver Dunk, Chromium Extensions
Thanks Oliver, I'll check out idle API!
Reply all
Reply to author
Forward
0 new messages