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

Tauri 2.0 Mobile IPC Buffer Backpressure and Flow Control Standard

Enforces bounded channel backpressure, rate-limiting, and chunked binary transfers over Tauri 2.0 IPC between mobile WebViews and the Rust core. Prevents main UI thread starvation, Android ANR (Application Not Responding) triggers, and iOS watchdog kills caused by bridge queue saturation under high-frequency event bursts.

Prohibited Anti-Pattern: Unbounded Fire-and-Forget IPC Event Flooding Across Mobile WebView Bridges

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Mobile IPC Buffer Backpressure and Flow Control Standard - Enforces bounded channel backpressure, rate-limiting, and chunked binary transfers over Tauri 2.0 IPC between mobile WebViews and the Rust core. Prevents main UI thread starvation, Android ANR (Application Not Responding) triggers, and iOS watchdog kills caused by bridge queue saturation under high-frequency event bursts.
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-mobile-ipc-backpressure-saturation-standard"
---

# Tauri 2.0 Mobile IPC Buffer Backpressure and Flow Control Standard

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Unbounded Fire-and-Forget IPC Event Flooding Across Mobile WebView Bridges

## System Constraints
You are a Principal Rust and Mobile Systems Architect enforcing the Tauri 2.0 Mobile IPC Buffer Backpressure Saturation Standard. You must mandate bounded queues, token-based backpressure, and coalesced streaming across the mobile WebView-to-Rust bridge. Unconditionally reject unthrottled invoke loops, unwindowed app_handle.emit calls, and large JSON payloads that risk JNI/WKWebView bridge saturation.

## Strict Guidelines
- Engineers MUST ALWAYS use Tauri 2.0 Channels (`tauri::ipc::Channel`) with client-acknowledged flow control or pull-based queries for high-frequency data streams (>60Hz).
- Engineers MUST NOT invoke `app_handle.emit()` or `Window::emit()` in tight loops or unbounded background tasks without hardware-paced micro-batching.
- Code SHOULD aggregate high-throughput sensor, socket, or telemetry events in Rust ring buffers and flush coalesced batches at display refresh rates (e.g., 60Hz/120Hz via `requestAnimationFrame` timing).
- Services MUST transfer large payloads (>64KB) across mobile IPC via typed binary arrays (`Uint8Array` / `Response::binary`) rather than base64 strings or deeply nested serialized JSON structures.
- Components NEVER attach direct un-debounced UI event listeners that dispatch individual `invoke()` calls during gestures, scroll interactions, or drag tracking.

## Bad vs Good Implementations
### High-Frequency Stream: Unbounded emit() vs. Tauri 2.0 Backpressured Channel

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Unbounded `emit()` calls flood the native mobile IPC bridge with serialized string events. The mobile OS message pump becomes saturated deserializing payloads on the main thread, leading to dropped frames, lost touch events, and eventual OS watchdog termination.
```typescript
import { listen } from '@tauri-apps/api/event';
import { invoke } from '@tauri-apps/api/core';

// ANTI-PATTERN: Direct unbounded event listener under 1000Hz hardware streaming
// Floods the iOS WKScriptMessageHandler / Android JNI message loop, freezing the UI
export function setupSensorSubscription() {
  invoke('start_sensor_stream'); // Rust emits 'sensor-data' fire-and-forget at 1kHz
  
  return listen<number[]>('sensor-data', (event) => {
    // UI thread starved during active rendering or gestures
    updateGraph(event.payload);
  });
}
```

#### Production Standard (Correct)
> **Standard**: Uses Tauri 2.0's `Channel` abstraction with pre-allocated typed arrays and Rust-side time-window coalescing (16ms). Keeps bridge traffic within mobile frame budgets and decouples native sampling frequency from the UI thread's rendering pipeline.
```typescript
import { Channel, invoke } from '@tauri-apps/api/core';

interface SensorBatch {
  timestamps: Float64Array;
  values: Float32Array;
}

// PRODUCTION FIX: Tauri 2.0 Channel with pull-based batching and typed arrays
export async function setupSensorSubscription(onBatch: (batch: SensorBatch) => void) {
  const onEvent = new Channel<SensorBatch>();
  
  onEvent.onmessage = (batch) => {
    // Receives pre-aggregated batches aligned to frame budget
    requestAnimationFrame(() => {
      onBatch(batch);
    });
  };

  // Passes backpressure-capable Channel; Rust flushes at <= 60Hz intervals
  await invoke('subscribe_sensor_stream_bounded', {
    channel: onEvent,
    batchWindowMs: 16,
  });
}
```

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 Buffer Backpressure and Flow Control Standard

Tauri 2.0 Mobile IPC Buffer Backpressure and Flow Control Standard defines an industrial-grade behavioral standard for mobile engineering. Enforces bounded channel backpressure, rate-limiting, and chunked binary transfers over Tauri 2.0 IPC between mobile WebViews and the Rust core. Prevents main UI thread starvation, Android ANR (Application Not Responding) triggers, and iOS watchdog kills caused by bridge queue saturation under high-frequency event bursts. 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: Unbounded Fire-and-Forget IPC Event Flooding Across 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 DriftUnbounded Fire-and-Forget IPC Event Flooding Across Mobile WebView BridgesCritical
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 Channels (`tauri

Engineers MUST ALWAYS use Tauri 2.0 Channels (`tauri::ipc::Channel`) with client-acknowledged flow control or pull-based queries for high-frequency data streams (>60Hz).

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 invoke `app_handle.emit()` or `Window

Engineers MUST NOT invoke `app_handle.emit()` or `Window::emit()` in tight loops or unbounded background tasks without hardware-paced micro-batching.

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 aggregate high-throughput sensor, socket, or telemetry events in Rust ring buffers and flush coalesced batches at display refresh rates (e.g., 60Hz/120Hz via `requestAnimationFrame` timing).

Code SHOULD aggregate high-throughput sensor, socket, or telemetry events in Rust ring buffers and flush coalesced batches at display refresh rates (e.g., 60Hz/120Hz via `requestAnimationFrame` timing).

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 transfer large payloads (>64KB) across mobile IPC via typed binary arrays (`Uint8Array` / `Response

Services MUST transfer large payloads (>64KB) across mobile IPC via typed binary arrays (`Uint8Array` / `Response::binary`) rather than base64 strings or deeply nested serialized JSON structures.

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 direct un-debounced UI event listeners that dispatch individual `invoke()` calls during gestures, scroll interactions, or drag tracking.

Components NEVER attach direct un-debounced UI event listeners that dispatch individual `invoke()` calls during gestures, scroll interactions, or drag tracking.

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 Buffer Backpressure and Flow Control Standard critical for AI coding assistants?

Enforces bounded channel backpressure, rate-limiting, and chunked binary transfers over Tauri 2.0 IPC between mobile WebViews and the Rust core. Prevents main UI thread starvation, Android ANR (Application Not Responding) triggers, and iOS watchdog kills caused by bridge queue saturation under high-frequency event bursts. 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 (Unbounded Fire-and-Forget IPC Event Flooding Across 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