Hello I am trying to code a Programm that runs all time and I tried to do it the classic way with a while(true) {…} condition.The problem is the programm always crashes after half a minute on my iphone.How can i make my programm run always repeat a task every time (for example fetching data from a website every … seconds).I appreciate your help, thank you.
Sounds like it is just crashing you out of an infinite loop as you run low on resources.
You could add a delay into the loop, but o note that Scriptable ll eventually time out.
You could switch to a scheduled check via Shortcuts, or deploy as a widget. But these will largely dictate the frequencies you can practically accomplish.
If you need more control, try switching to a different device running a non-mobile OS as the resource management and constraints will likely allow ou much more flexibility.
2 Likes
This could be an “object lifecycle” issue. I have no idea how javascript does garbage collection but:
- Maybe objects are accumulating and not being garbage collected. That would be a programming issue, in all likelihood.
- Maybe the “external force” way of looping tears down the environment (enough) to effectively empty the heap.
I’d rather solve such a problem within the program than by restarting the program, of course.
1 Like