2

When writing values to the registry, does this really have to be done using a task Task ?

Snippet from https://sdkdocs.roku.com/display/sdkdoc/BrightScript+Support

  • roRegistry : Can only be used in a Task node
  • roRegistrySection : Can only be used in a Task node

I've written to the registry successfully with and without the use of a Task.

Fabii
  • 3,820
  • 14
  • 51
  • 92

2 Answers2

3

Well only because you can doesn't mean you should! Writing to registry should be done only in task since doing it that way ensures that Your UI will not be blocked while writing data to the registry. It's a bad practice to write data to registry from the render thread.

EDIT: I would just like to add official response from ROKU on this subject and 8.0 version of the ROKU OS where they recommend using the TASK still. This stack overflow question/thread is mentioned there as well. https://community.roku.com/t5/Roku-Developer-Program/Registry-and-Task-Nodes/td-p/497169

U.Mitic
  • 744
  • 1
  • 6
  • 14
  • 1
    yeah I figured, I understand that there is a possibility of blocking the UI if a large amount data is being written to the registtry. I just think its a bit of overkill to have to set up a task and callback to write a simple string value to the registry. Anyhow , gracias and I will use a Task as suggested. – Fabii Jun 21 '18 at 16:43
  • 1
    The documentation is just wrong/outdated. The docs are not recommending to use a Task for performance reasons, they are stating that the `roRegistry` and `roRegistrySection` components can ONLY be used in a task thread, this was true prior to firmware 8.0, they just haven't updated the docs. – Alejandro Cotilla Jun 21 '18 at 17:23
  • @AlejandroCotilla , so it's not necessary to use a Task to write to registry ? – Fabii Jun 21 '18 at 17:48
  • @Fabii Correct, not necessary anymore, and you will probably not see any performance issues by doing so. – Alejandro Cotilla Jun 21 '18 at 18:24
  • 1
    FYI, `ReadAsciiFile()` can be used in the render thread as well since firmware 8.0. – Alejandro Cotilla Jun 21 '18 at 18:30
  • @AlejandroCotilla You should write an explicit answer to help others find correct information. – Jonny Jun 24 '19 at 06:32
3

No, a Task node is not required to use the roRegistry or the roRegistrySection components, the documentation is just wrong/outdated.

Prior to firmware 8.0 a Task node was required, but that is not the case anymore. Both components can safely be used in the render thread.

ReadAsciiFile() can also be used in the render thread since firmware 8.0 and they haven't updated that either.

Alejandro Cotilla
  • 2,501
  • 1
  • 20
  • 35