NIB / DOCUMENTATION
Limits and performance — NibGenUI
Bound each stream and distinguish local tests from target-device evidence.
Open interactive viewBudget a session before opening its stream
Choose limits from the task you intend to show. A short profile form may need one surface, a handful of nodes and a small data model. A dashboard may need more. Give the runtime enough room for valid intermediate frames, including detached definitions, but do not raise every limit just to make malformed input pass. Per-message bytes, retained model bytes and total protocol attempts constrain different resources.
The constructor below is an example for a small local session. It does not represent a universal safe setting. Eight kilobytes bounds one envelope, while four kilobytes bounds the retained data model after updates. Twenty-four nodes permits temporary definitions around a small form. A hundred protocol attempts counts rejected messages too. Local typing through writeData does not consume those protocol attempts.
final runtime = NibRuntime(
catalogs: [NibCatalog.basic()],
maxMessageBytes: 8192,
maxDataModelBytes: 4096,
maxNodes: 24,
maxSurfaces: 1,
maxDepth: 8,
maxStringLength: 512,
maxProtocolMessages: 100,
);Set a complete-stream deadline
NibHttpTransport.connect needs an explicit allowedSurfaceIds set. It defaults to 8 MiB and 1024 frames per connection. Its 30-second timeout covers connection setup and the entire response body; active frames do not reset it. The adapter has no independent inactivity timer.
Cancel the stream subscription to abort the request. The host owns reconnect and backoff, total session time, authentication headers, and endpoint selection. Browser use requires the server’s CORS policy.
| API | Type | Default | Behavior |
|---|---|---|---|
| allowedSurfaceIds | Set<String> | required | Surface ownership allowlist for one HTTP stream. |
| maxStreamBytes | int | 8 × 1024 × 1024 | Maximum complete response bytes per connection. |
| maxFrames | int | 1024 | Maximum response frames per connection. |
| timeout | Duration | 30 seconds | Hard connection-plus-body deadline, not idle timeout. |
Separate connection, inactivity and session limits
Add nib_genui_http from the same local checkout only after the fixture works. Supply an http.Client and a host-selected endpoint; neither is generated by the UI stream. The transport’s default 30-second timeout is a hard connection-plus-body deadline. A stream that keeps delivering frames still ends at that deadline. An inactivity timer would instead reset on progress, and the adapter does not provide one independently.
If your host needs inactivity detection, define what counts as progress. A completed valid frame is different from a peer sending one byte forever. Also cap total session time and reconnection attempts. Making a new adapter resets its frame counter, while the same runtime retains its protocol-attempt budget. Automatically recreating both on every failure would defeat the session boundary you intended.
Test a finite successful response, a stalled connection, malformed JSONL, a frame beyond the byte limit, and a response for a disallowed surface. Confirm that rejection preserves the previous valid surface and that cancellation stops further updates. On the web, test the actual origin and CORS response; a passing fake-client test cannot establish browser permission to read a server response.
The local demo has no network and deliberately permits three frames. Use it to learn bounded replay, not to infer transport throughput. Measure decode, validation, widget build and raster work separately with representative bursts on target hardware. Resource fetches, a broad widget catalog and production authorization remain outside this built-in slice; adding a custom builder means designing and testing those responsibilities yourself.
No resource widget yet
The Basic subset has no URL or media resource component. There is therefore no production resource fetch policy to rely on. If a trusted custom builder fetches URLs, the host owns scheme, origin, redirect, size, and permission checks before it is used.
This package slice does not run generated code. Registered host functions should be deterministic, side-effect-free string functions; they are not a way to smuggle a network call into the data model.
Measure the host and device separately
Pure Dart reduction tests and Flutter widget tests do not establish device frame time, raster cost, memory retention, or screen-reader behavior. Measure large surface updates, stream bursts, and repeated disposal in the host and renderer you plan to support.
A successful build shows that a target compiled. It does not show that text input, scrolling, focus and memory behave correctly on a physical device. Record those checks separately, and describe the platforms you actually exercised when sharing an integration.