11-22-2017 12:32
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


11-22-2017 12:32
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
You may begin to see this message within your applications, so it's important to understand why this occurs and how to resolve it.
This message is shown when an app has spent too much time without giving control back to the operating system. It is more likely to happen if there are a lot of events being delivered to the app. For example, when the user is touching the screen or when the app is receiving lots of messages from the companion, or from sensors.
In the worst case, if your app is busy for 10s, it will be killed.
If you need to do long calculations you should break them down in small chunks and chain them via a call to setTimeout(continueWorkFunction, 1). This will give the system time to process events before continuing your work.
For example:
var N = 10; var myElements = Array.apply(null, {length: N}).map(Number.call, Number) function updateDisplay(startIndex = 0) { for (let i = startIndex; i < myElements.length; i++) { updateElement(myElements[i]); if (i - startIndex >= 3) { setTimeout(updateDisplay.bind(this, i + 1), 1); console.log("taking a break..."); break; } } } function updateElement(e) { console.log(e); }
