Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
sjb64
Roku Guru

Wait vs Sleep

This is all just experimenting, so am curious about it...

If I create a roVideoScreen page and run my event loop in a tight Port.GetMessage() loop, I can completely disable* HLS playback in the process, I assume by starving the CPU from being able to do anything else. Changing the GetMessage to a Wait makes everything run perfectly. This all seems perfectly sensible to me, and what I would have expected.

But, when I use the Port.GetMessage() loop, and put in a Sleep(1) call in the loop, my expectation would be that everything runs fine, as sleep does its pause "without wasting CPU cycles" per the docs. But the reality seems to be that the CPU is still starved and HLS playback is still completely disabled.

I would have guessed the script blocking done by Wait and the script blocking done by Sleep were similar, but they're it looks like not.

So my question is this - Is Sleep a CPU cycle eating pause (which seems contrary to the docs)?

* By disabled I mean it results in an "Unspecified or invalid track path/url" failure after a bit (on a perfectly good URL that works fine with Wait).
0 Kudos
2 REPLIES 2
EnTerr
Roku Guru

Re: Wait vs Sleep

What device?
I suspect your mileage may vary, 3xxx vs 4xxx vs 5xxx/27xx.
0 Kudos
sjb64
Roku Guru

Re: Wait vs Sleep

4200X
0 Kudos
Community is Temporarily in Read-Only Mode!

We’re upgrading Roku Community to bring you a faster, more mobile-friendly experience. You may notice limited functionality or read-only access during this time. You will not be able to log in or post new comments or kudos during this time. Read more here.

Planned Downtime:
Community will be unavailable for up to 24–48 hours during the upgrade window during the week of May 12 and you may notice reduced functionality. In the meantime, for additional assistance, visit our Support Site.

Thanks for your patience — we’re excited to share what’s next!