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

Tauri 2.0 Mobile IPC Binary Fast-Path & Zero-Copy Memory Guardrail

Enforces raw binary ArrayBuffer boundaries across Tauri 2.0 IPC bridges for payloads exceeding 32KB or high-frequency operations on mobile runtimes. Prohibits base64 encoding and monolithic serde_json serialization over the mobile WebView message handler to eliminate bridge thread blocking and out-of-memory crashes.

Prohibited Anti-Pattern: Base64-encoded strings and monolithic JSON arrays across Tauri 2.0 mobile WebView bridges.

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Mobile IPC Binary Fast-Path & Zero-Copy Memory Guardrail - Enforces raw binary ArrayBuffer boundaries across Tauri 2.0 IPC bridges for payloads exceeding 32KB or high-frequency operations on mobile runtimes. Prohibits base64 encoding and monolithic serde_json serialization over the mobile WebView message handler to eliminate bridge thread blocking and out-of-memory crashes.
globs: src/**/*.{ts,tsx}, src-tauri/src/**/*.rs
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/tauri-v2-ipc-binary-fastpath-guardrail"
---

# Tauri 2.0 Mobile IPC Binary Fast-Path & Zero-Copy Memory Guardrail

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Base64-encoded strings and monolithic JSON arrays across Tauri 2.0 mobile WebView bridges.

## System Constraints
You are a Principal Mobile Systems Architect enforcing Tauri 2.0 zero-copy and binary fast-path IPC invariants. WebViews on iOS (WKWebView) and Android (Chromium WebView) incur heavy string copy and JSON serialization penalties that trigger thermal throttling and WebProcess terminations. You must mandate binary typed array transfers and Rust-side raw payload consumption for all large or high-throughput data streams.

## Strict Guidelines
- Engineers MUST ALWAYS transfer binary data (audio, camera frames, files, tensors) using raw Uint8Array payloads or Tauri 2.0 Channel streams rather than Base64 or number arrays.
- Engineers MUST NOT serialize payloads larger than 32KB into JSON strings or serde_json::Value objects across the IPC bridge.
- Code SHOULD consume incoming binary responses as ArrayBuffer on the frontend and release references immediately to avoid mobile WebView garbage collection pressure.
- Services MUST implement tauri::ipc::Request and tauri::ipc::Response with raw bytes (Vec<u8> or bytes::Bytes) on the Rust backend for binary fast-paths.
- Components NEVER hold unmanaged ArrayBuffer references across long-lived component lifecycles without explicit explicit teardown or transfer semantics.

## Bad vs Good Implementations
### Binary Frame Transfer: Base64 JSON Bridge vs Tauri 2.0 Raw IPC

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Iterating over an ArrayBuffer to build a binary string and base64 encoding causes triple-buffering in the JS heap. Passing this as a JSON field forces the native bridge to parse giant JSON strings, causing frame drops and potential WKWebView Jetsam OOM kills on iOS.
```typescript
import { invoke } from '@tauri-apps/api/core';

// ANTI-PATTERN: Base64 serialization causes duplicate string allocations,
// bridge thread lockup, and WKWebView crash on iOS when passing camera/sensor frames.
export async function uploadFrame(buffer: ArrayBuffer): Promise<string> {
  const bytes = new Uint8Array(buffer);
  let binary = '';
  for (let i = 0; i < bytes.byteLength; i++) {
    binary += String.fromCharCode(bytes[i]);
  }
  const base64Data = btoa(binary);

  // Transmits multi-megabyte JSON string through IPC
  return await invoke<string>('process_frame', {
    payload: {
      format: 'rgba',
      data: base64Data,
    },
  });
}
```

#### Production Standard (Correct)
> **Standard**: Transfers the raw Uint8Array via Tauri 2.0's native binary fast-path. The Rust core receives a raw byte slice without base64 decoding or serde_json traversal, maintaining sub-millisecond bridge latency and low memory footprint.
```typescript
import { invoke } from '@tauri-apps/api/core';

// PRODUCTION INVARIANT: Direct raw binary transfer via Tauri 2.0 binary IPC invoke.
// Bypasses JSON serialization entirely, transferring the Uint8Array directly to Rust.
export async function uploadFrame(buffer: ArrayBuffer): Promise<Uint8Array> {
  const rawBytes = new Uint8Array(buffer);
  
  // Tauri 2.0 supports binary payloads directly via raw Uint8Array
  const response = await invoke<ArrayBuffer>('process_frame_fast_path', rawBytes, {
    headers: {
      'content-type': 'application/octet-stream',
      'x-pixel-format': 'rgba',
    },
  });

  return new Uint8Array(response);
}
```

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 Binary Fast-Path & Zero-Copy Memory Guardrail

Tauri 2.0 Mobile IPC Binary Fast-Path & Zero-Copy Memory Guardrail defines an industrial-grade behavioral standard for mobile engineering. Enforces raw binary ArrayBuffer boundaries across Tauri 2.0 IPC bridges for payloads exceeding 32KB or high-frequency operations on mobile runtimes. Prohibits base64 encoding and monolithic serde_json serialization over the mobile WebView message handler to eliminate bridge thread blocking and out-of-memory crashes. 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: Base64-encoded strings and monolithic JSON arrays across Tauri 2.0 mobile WebView bridges. 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 DriftBase64-encoded strings and monolithic JSON arrays across Tauri 2.0 mobile WebView bridges.Critical
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 transfer binary data (audio, camera frames, files, tensors) using raw Uint8Array payloads or Tauri 2.0 Channel streams rather than Base64 or number arrays.

Engineers MUST ALWAYS transfer binary data (audio, camera frames, files, tensors) using raw Uint8Array payloads or Tauri 2.0 Channel streams rather than Base64 or number arrays.

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 serialize payloads larger than 32KB into JSON strings or serde_json

Engineers MUST NOT serialize payloads larger than 32KB into JSON strings or serde_json::Value objects across the IPC bridge.

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 consume incoming binary responses as ArrayBuffer on the frontend and release references immediately to avoid mobile WebView garbage collection pressure.

Code SHOULD consume incoming binary responses as ArrayBuffer on the frontend and release references immediately to avoid mobile WebView garbage collection pressure.

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 tauri

Services MUST implement tauri::ipc::Request and tauri::ipc::Response with raw bytes (Vec<u8> or bytes::Bytes) on the Rust backend for binary fast-paths.

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 hold unmanaged ArrayBuffer references across long-lived component lifecycles without explicit explicit teardown or transfer semantics.

Components NEVER hold unmanaged ArrayBuffer references across long-lived component lifecycles without explicit explicit teardown or transfer semantics.

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 Binary Fast-Path & Zero-Copy Memory Guardrail critical for AI coding assistants?

Enforces raw binary ArrayBuffer boundaries across Tauri 2.0 IPC bridges for payloads exceeding 32KB or high-frequency operations on mobile runtimes. Prohibits base64 encoding and monolithic serde_json serialization over the mobile WebView message handler to eliminate bridge thread blocking and out-of-memory crashes. 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 (Base64-encoded strings and monolithic JSON arrays across Tauri 2.0 mobile WebView bridges.) 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