Table of Contents

Core Concepts

The five ideas that everything else in this documentation builds on.

Table of Contents

The Engine Is a Separate Process

Channels Are Named, and the Name Matters

Events Are One-Way and Untyped on the Wire

Model Objects Are a View Over Bytes

Who Starts What

Putting It Together

The Engine Is a Separate Process

sbengine is the Crank Storyboard Engine. It loads an exported .gapp, draws it, and handles touch. Your application is a different process entirely and communicates with it only over SBIO.

This has consequences worth internalising early:

  • You cannot query the UI. There is no "what is currently displayed?" call. If your application needs to know, it must have sent the value itself or been told through an inbound event.
  • The UI keeps running if your application stops, showing whatever it last received. A frozen display does not mean a frozen engine.
  • Startup is racy by nature. Channels cannot open until the engine has created them, so the client waits. See Client Lifecycle.

Channels Are Named, and the Name Matters

An SBIO channel is a named, unidirectional pipe. Your application opens channels by name, and the engine opens the matching ones.

The name your application must use is the Storyboard application name — the value stored in the app/n node of the .gde model. It is not the .gde filename, and it is not storyboardAppName from StoryboardConfiguration.json (which is the filename).

The app node of the .gde model, highlighting the application name

Two rules follow:

Rule Consequence of breaking it
The name must match the engine's application name The channel never opens; the client waits forever, warning every 30 seconds
The name must be 25 characters or fewer SBIO cannot create it; the client warns at open time

Events Are One-Way and Untyped on the Wire

Each event is declared in the Storyboard project's events/custom.evt with a name, a type (direction), and a format string describing its fields.

<event format="2u1 value 1u1 increase" name="change_brightness" type="0x20">
  <field name="increase"/>
  <field name="value"/>
</event>

On the wire an event is just its name, its format, and a flat byte buffer. Nothing validates that the bytes match the format — if the two sides disagree about a field's size, the values simply come out wrong. Code generation exists to stop the two sides disagreeing.

See Events & the SBIO Format String.

Model Objects Are a View Over Bytes

A generated model class does not hold your data. It holds a StoryboardMessage, and every property reads or writes that message's byte buffer directly through the field layout in the generated metadata.

update.CurrentTemperature = 58;   // writes 2 bytes at the field's offset
var t = update.CurrentTemperature; // reads them back

Three things follow from this that surprise people:

  • Writing an unchanged value does nothing. No property-changed notification, no behaviors. This is usually what you want, but it means a "refresh" by rewriting the same values is a no-op.
  • Strings are special. A string field is variable length, so writing one reallocates the buffer. It must be the last field in its event.
  • Equal-length strings can appear not to update. The buffer is only committed when its length changes, so swapping "IDLE" for "STOP" may not reach the display. Make status labels differ in length, or pad them.

See View Models & Property Binding.

Who Starts What

This is the single biggest behavioural difference between running on your desk and running on a display.

Where Who starts sbengine Which engine folder
Windows StoryboardClient storyboardDebugEngineFolder
macOS StoryboardClient storyboardDebugEngineFolder
Desktop Linux StoryboardClient storyboardDebugEngineFolder
OpenView display The generated UI start script storyboardEngineFolder, copied into the package

The client decides by asking whether it is running on a target, not by checking the OS — a display is also Linux, so the target check has to come first. StartStoryboardUI() is called the same way in both cases; on a device it skips the launch and only opens channels.

Note

This is why pkill -x sbengine on shutdown matters, and why the client matches the process name exactly. On a development machine a looser match would also kill editors and build processes that merely mention sbengine on their command line.

Putting It Together

sequenceDiagram
    participant App as Your application
    participant Client as StoryboardClient
    participant Engine as sbengine
    participant UI as Display

    App->>Client: AddOutputChannel("thermostat_frontend")
    App->>Client: AddInputChannel("thermostat_backend")
    App->>Client: StartStoryboardUI()
    Client->>Engine: start process (desktop only)
    Client->>Engine: open channels (retries until created)
    App->>Client: StartEventListenerAsync()

    Note over App,UI: steady state

    App->>Client: SendEvent(update.Message)
    Client->>Engine: thermostat_update + bytes
    Engine->>UI: redraw

    UI->>Engine: touch
    Engine->>Client: change_brightness + bytes
    Client->>App: MessageReceived

Next: Configuration Reference for the settings that drive all of this, or Client Lifecycle for the start and stop sequence in detail.