This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
mobilecritical PriorityID: tauri-v2-mobile-ipc-zero-copy-binary-stream-standard

Tauri 2.0 Mobile IPC Zero-Copy Binary & Telemetry Streaming Guardrail

Enforces zero-copy raw binary transfer protocols and dedicated Web Worker offloading for high-frequency telemetry and sensor streams in Tauri 2.0 mobile applications. Eliminates JSON serialization, base64 encoding overhead, and main-thread event listener saturation that triggers Android/iOS WebView UI jank and severe frame drops.

Prohibited Anti-Pattern: Serializing High-Frequency Binary Telemetry to JSON or Base64 over the Tauri Main Thread IPC Bridge

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Mobile IPC Zero-Copy Binary & Telemetry Streaming Guardrail - Enforces zero-copy raw binary transfer protocols and dedicated Web Worker offloading for high-frequency telemetry and sensor streams in Tauri 2.0 mobile applications. Eliminates JSON serialization, base64 encoding overhead, and main-thread event listener saturation that triggers Android/iOS WebView UI jank and severe frame drops.
globs: src/**/*.{ts,tsx,js}, src-tauri/src/**/*.rs
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/tauri-v2-mobile-ipc-zero-copy-binary-stream-standard"
---

# Tauri 2.0 Mobile IPC Zero-Copy Binary & Telemetry Streaming Guardrail

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Serializing High-Frequency Binary Telemetry to JSON or Base64 over the Tauri Main Thread IPC Bridge

## System Constraints
You are a Principal Mobile Architect enforcing the Tauri 2.0 IPC Zero-Copy Shared Array Buffer Transfer Standard. You mandate zero-copy binary pipelines using Tauri 2.0 Channels or Raw Binary IPC responses for continuous sensor, audio, video, or telemetry synchronization. Reject any implementation that serializes byte payloads to JSON or base64, or processes high-frequency (>30Hz) streams directly on the WebView UI main thread.

## Strict Guidelines
- Engineers MUST ALWAYS use Tauri 2.0 `Channel<Uint8Array>` or `Response::new(Vec<u8>)` for streaming binary payloads rather than JSON-serialized payloads or base64 strings.
- Engineers MUST NOT consume high-frequency (>30Hz) telemetry streams on the WebView main execution thread; ingestion MUST occur within a dedicated Web Worker.
- Code SHOULD leverage zero-copy `ArrayBuffer` transfer semantics (`postMessage(buffer, [buffer])`) when passing received IPC byte blocks from background ingest workers to rendering pipelines.
- Services MUST implement typed array recycling or ring buffers (ArrayBuffer pools) on the frontend to prevent garbage collection pauses during sustained streaming.
- Components NEVER attach global event listeners (`listen('telemetry-event', ...)`) for high-throughput streaming data, as Tauri's event bus relies on string serialization.

## Bad vs Good Implementations
### High-Frequency Telemetry Ingestion (Main Thread JSON vs Web Worker Binary Channel)

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Using Tauri's global event listener parses JSON on the WebView main thread. For high-frequency telemetry, converting arrays of numbers or decoding base64 triggers high CPU utilization, memory pressure, and visible 60fps drops on mobile devices.
```typescript
import { listen } from '@tauri-apps/api/event';

// ANTI-PATTERN: Listens to Tauri global event bus on WebView main thread
// Serializes binary data to base64 or JSON numbers; blocks UI thread at 60Hz
interface SensorPayload {
  timestamp: number;
  readings: number[]; // Array of 2048 floats serialized into JSON
}

export function initSensorStream() {
  listen<SensorPayload>('sensor://telemetry', (event) => {
    // UI stalls on mobile WebViews due to JSON.parse overhead and GC churn
    const data = new Float32Array(event.payload.readings);
    window.dispatchEvent(new CustomEvent('render-frame', { detail: data }));
  });
}
```

#### Production Standard (Correct)
> **Standard**: Employs Tauri 2.0 Channels with raw Uint8Array buffers, ingested within a background Web Worker. The underlying IPC uses direct binary chunks without JSON/base64 overhead, and transfer semantics prevent WebView UI thread contention.
```typescript
import { Channel, invoke } from '@tauri-apps/api/core';

// PRODUCTION INVARIANT: Offloaded binary channel ingestion inside dedicated Web Worker
export function setupWorkerPipeline() {
  const worker = new Worker(new URL('./telemetry.worker.ts', import.meta.url), {
    type: 'module',
  });

  // In telemetry.worker.ts:
  // const onChunk = new Channel<Uint8Array>();
  // onChunk.onmessage = (chunk: Uint8Array) => {
  //   const buffer = chunk.buffer;
  //   // Zero-copy transfer to canvas/processing worker without main-thread stall
  //   self.postMessage({ buffer, byteOffset: chunk.byteOffset, length: chunk.byteLength }, [buffer]);
  // };
  // invoke('start_telemetry_stream', { onChunk });

  worker.onmessage = (e: MessageEvent<{ buffer: ArrayBuffer }>) => {
    const view = new Float32Array(e.data.buffer);
    // Lightweight consumption of transferrable buffer
    console.debug('Received binary frame:', view.byteLength);
  };
}
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Recommended Agent Skills (askills.dev)

Ready-to-use executable skill functions tailored to this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Tauri 2.0 Mobile IPC Zero-Copy Binary & Telemetry Streaming Guardrail

Tauri 2.0 Mobile IPC Zero-Copy Binary & Telemetry Streaming Guardrail defines an industrial-grade behavioral standard for mobile engineering. Enforces zero-copy raw binary transfer protocols and dedicated Web Worker offloading for high-frequency telemetry and sensor streams in Tauri 2.0 mobile applications. Eliminates JSON serialization, base64 encoding overhead, and main-thread event listener saturation that triggers Android/iOS WebView UI jank and severe frame drops. Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.

Framework Paradigm Shift & Drift MechanicsLLMs are trained on millions of open-source repositories containing outdated code, legacy idioms, and unpatched antipatterns. When coding assistants generate implementations for this stack, they default to common statistical tokens: Serializing High-Frequency Binary Telemetry to JSON or Base64 over the Tauri Main Thread IPC Bridge Without an explicit system instruction file, developers spend hours debugging silent failures.
Failure Modes & Production Blast Radius

Hazard Analysis: What Breaks Without This Rule

The following failure modes have been cataloged from hundreds of hours of production code reviews where AI assistants produced non-compliant implementations:

Failure ModeAI Symptom (The Anti-Pattern)SeverityProduction Impact & Remedy
AI Hallucination & Deprecation DriftSerializing High-Frequency Binary Telemetry to JSON or Base64 over the Tauri Main Thread IPC BridgeCritical
Violating this industrial standard introduces regression bugs, security risks, and unexpected runtime failures in production.
Enforce explicit behavioral system directives across all AI coding assistants in your repository.
Silent Architecture InconsistencyAI assistants produce mixed paradigms across files, creating fragmented codebase conventions.Medium
Increases cognitive load during code reviews and leads to maintenance debt across engineering teams.
Pin project conventions in .cursor/rules, CLAUDE.md, and AGENTS.md so all team agents follow identical guardrails.
Architectural Directives in Detail

Step-by-Step Production Directives

Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:

1

Engineers MUST ALWAYS use Tauri 2.0 `Channel<Uint8Array>` or `Response

Engineers MUST ALWAYS use Tauri 2.0 `Channel<Uint8Array>` or `Response::new(Vec<u8>)` for streaming binary payloads rather than JSON-serialized payloads or base64 strings.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
2

Engineers MUST NOT consume high-frequency (>30Hz) telemetry streams on the WebView main execution thread

Engineers MUST NOT consume high-frequency (>30Hz) telemetry streams on the WebView main execution thread; ingestion MUST occur within a dedicated Web Worker.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
3

Code SHOULD leverage zero-copy `ArrayBuffer` transfer semantics (`postMessage(buffer, [buffer])`) when passing received IPC byte blocks from background ingest workers to rendering pipelines.

Code SHOULD leverage zero-copy `ArrayBuffer` transfer semantics (`postMessage(buffer, [buffer])`) when passing received IPC byte blocks from background ingest workers to rendering pipelines.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
4

Services MUST implement typed array recycling or ring buffers (ArrayBuffer pools) on the frontend to prevent garbage collection pauses during sustained streaming.

Services MUST implement typed array recycling or ring buffers (ArrayBuffer pools) on the frontend to prevent garbage collection pauses during sustained streaming.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
5

Components NEVER attach global event listeners (`listen('telemetry-event', ...)`) for high-throughput streaming data, as Tauri's event bus relies on string serialization.

Components NEVER attach global event listeners (`listen('telemetry-event', ...)`) for high-throughput streaming data, as Tauri's event bus relies on string serialization.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
Technical Questions & Answers

Frequently Asked Technical Questions

Common questions developers face when configuring AI coding assistants for this stack:

Q:Why is Tauri 2.0 Mobile IPC Zero-Copy Binary & Telemetry Streaming Guardrail critical for AI coding assistants?

Enforces zero-copy raw binary transfer protocols and dedicated Web Worker offloading for high-frequency telemetry and sensor streams in Tauri 2.0 mobile applications. Eliminates JSON serialization, base64 encoding overhead, and main-thread event listener saturation that triggers Android/iOS WebView UI jank and severe frame drops. Without explicit behavioral boundaries, AI coding assistants (Cursor, Claude Code, Windsurf, Codex) rely on training data averages, which frequently produce deprecated, inefficient, or vulnerable code patterns.

Q:How does adopting this rule prevent AI hallucinations?

This rule explicitly declares what the AI must avoid (Serializing High-Frequency Binary Telemetry to JSON or Base64 over the Tauri Main Thread IPC Bridge) and prescribes verified positive examples. Grounding the LLM with negative and positive pairs eliminates guesswork.

Q:Which AI coding environments are supported?

This specification is multi-platform compatible: Cursor (.cursor/rules/*.mdc & .cursorrules), Anthropic Claude Code (CLAUDE.md), Windsurf (.windsurfrules), Codex / Cline (AGENTS.md), and GitHub Copilot (.github/copilot-instructions.md).

Q:Can I combine this rule with other technology stacks?

Yes. Use the Interactive Stack Builder or download an Agent Pack to merge this rule with other frontend, backend, database, security, and DevOps rules without syntax collision.

Open Specification · CC BY 4.0·Free for Personal, Team & Commercial In-Repo Use

Citation & Open Source Attribution Guidelines

This specification is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). You are completely free to adapt and share this rule in your workspace. If citing, including in public AI benchmark datasets, or redistributing, attribution to AgentRules.org is required.

Related MOBILE Rules

View all rules →
1 Rule in Stack

Tauri