Hello!
I have a focus timer/website blocker extension. But this post is mostly about the focus timer.
Before manifest v3, it was very easy to run a long-running task such as a setInterval, as it persisted. But after v3, it caused a lot of issues since the lifecycle of the worker is short-lived; APIs like setInterval wouldn’t work as expected.
Since then, I’ve been using alarms, and here are a few observations
I’m aware all these are mentioned in the docs, but I have a proposal
Issue 1 and Issue 2While I understand alarms can be very heavy on the user's system and running them each second requires significant memory and causes perf issues, we need something better, something more accurate.
Currently, even scheduling a single alarm, 15m or 25m in the future, it fires unreliably. Always firing a few seconds late.
My suggestion is that even if you don’t support minute accuracy, it would be nice to have accurate scheduling. Just throwing some ideas around: maybe allow for a pool of 5-6 accurate schedules per hour, or allocate some memory or give the devs access to a queue (with limits), that they can push schedules into?
Issue 3Testing alarms is a pain on unpacked version and runtime prod version. Everything seems to work really well on the local machine, but as soon as you try the live runtime version, everything breaks. It becomes really hard to pinpoint issues when alarms are involved. On local versions, Chrome lets you run alarms up to minute accuracy. This isn’t the case on prod.
My suggestion would be to have some kind of flag that allows you to run the exact runtime env for unpacked versions. That way it becomes easier to debug alarm drift/delay issues.
My workaroundRight now, my workaround is a bit wonky. I’m using offscreen and alarms to run my timer. And I’m being very pragmatic with my code; I only run the alarms once a minute (since I don’t care when it fires if its not < 60s), and once the timer duration reaches < 60, i hand the controls over to an offscreen which then runs a setInterval. I want the ending to be very accurate and fire exactly at the end time.
Before using this workaround, the alarms would fire at unreliable end times many seconds after the actual timer had ended. This caused a lot of my users to think the extension is broken (cause it stopped at 0:00 and didn’t end the timer session). And it was really hard to pinpoint this issue because it worked fine unpacked. I have tested this on the runtime version, and it seems to hold. I’m using “WORKER” reason for the offscreen, as it keeps the offscreen open indefinitely.
My suggestion would be to introduce another official reason called “INTERVAL” or “TIMER”.
Anyways that's all I can think of right now. Hope you can consider my suggestions!
P.S: Chrome store reviews got faster; thanks to that, I was able to push multiple hot fixes for my extension. Please convey my thanks to the review team.
-Ben
Currently, even scheduling a single alarm, 15m or 25m in the future, it fires unreliably. Always firing a few seconds late.
On local versions, Chrome lets you run alarms up to minute accuracy. This isn’t the case on prod.
--
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 visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/b5353c0f-a775-4edb-899e-74e5c9e70986n%40chromium.org.