Skip to main content
m.global is a special roSGNode provided by the Roku SceneGraph runtime. Unlike local m fields, m.global is shared across all components and tasks simultaneously — reads and writes are thread-safe and changes are immediately visible to any observer registered with observeField. GTV_InitGlobalState() in source/AppState.brs calls m.global.addFields({...}) once at startup inside MainScene.init() to declare every field with its initial value.

Reading and writing global fields

From a component (render thread):
From a Task node (background thread) — Tasks access m.global through the same m.global reference available in their script scope:
Observing changes — components can react to global field changes:
Tasks should write to their own output fields (e.g., done, result) rather than writing directly to m.global. MainScene reads task output and updates m.global on the render thread. This avoids race conditions between the render thread and task threads.

Field reference

Server and connectivity

Authentication

authReasonCode constants are defined in AppConstants() as AUTH_REASON_NONE, AUTH_REASON_NETWORK_DOWN, AUTH_REASON_CREDENTIALS, AUTH_REASON_INACTIVE, and AUTH_REASON_PASSWORD_CHANGED.

Channel list and selection

Player state

Ad state

Device info

launchDeepLink and inputDeepLink are fields on m.top (the MainScene node), not on m.global. They are declared in MainScene.xml with onChange handlers and appear here for completeness.

Complete initialisation listing

The full addFields call from source/AppState.brs:

Registry fields

Some state is persisted across sessions in the Roku Registry (roRegistrySection named "GlobalTV"). These values survive channel updates and device reboots.
Credentials are stored in plaintext in the Roku Registry. The registry is device-local and not accessible to other channels, but you should not store sensitive data beyond what is required for auto-login.

State lifecycle

The following events reset or clear portions of global state: