01 Executive Verdict & Core Concept تعریف و چشم‌انداز بنیادین (Executive Verdict)

RemoteCompose is Android's next-generation declarative remote UI framework designed in the Android Open Source Project (AOSP) and Jetpack Compose. It enables applications or cloud backends to serialize an entire interactive Compose UI tree and vector drawing pipeline into a compact, high-efficiency binary bytecode stream (.rc wire format) that is rendered, animated, and interacted with on another device, display, or sandboxed process without transferring executable code. RemoteCompose نسل نوین فریم‌ورک رابط کاربری راه دور (Remote UI) در پروژه متن‌باز اندروید (AOSP) و Jetpack Compose است. این فناوری به برنامه‌ها و سرورهای ابری اجازه می‌دهد که یک درخت رابط کاربری تعاملی کامپوز و خط لوله ترسیم برداری را درون یک رشته بایت فشرده باینری (فرمت بایت‌کد .rc) سریال‌سازی کرده و آن را در دستگاه، نمایشگر یا پروسه ایزوله دیگر بدون نیاز به انتقال کدهای اجرایی رندر، متحرک‌سازی و مدیریت کنند.
⚡

Binary Wire Format پروتکل باینری فوق فشرده

Replaces bulky JSON, XML layouts, and Parcelable IPC envelopes with an OpCode-driven flat byte buffer (WireBuffer), slashing cross-process and network payloads by 85–90%. با جایگزینی ساختارهای سنگین JSON، کدهای XML و بسته‌های حجیم Parcelable با یک بافر مسطح از کدهای عملیاتی (WireBuffer)، حجم داده‌های بین‌پراسی و شبکه را تا ۸۵ الی ۹۰ درصد کاهش می‌دهد.

🧮

Embedded RPN Engine موتور ریاضی و محاسبات محلی RPN

Contains an embedded Reverse Polish Notation (RPN) mathematical virtual machine that evaluates dynamic expressions, physics springs, and gestures at 60/120 FPS locally on the Player hardware. مجهز به یک ماشین مجازی مبتنی بر نمادگذاری معکوس لهستانی (RPN) است که محاسبات متغیرها، انیمیشن‌های فیزیکی و بازخورد لمسی را با نرخ ۶۰ و ۱۲۰ فریم بر ثانیه مستقیماً در سخت‌افزار پخش‌کننده اجرا می‌کند.

🛡️

Hermetic Sandbox ایزولاسیون و امنیت سخت‌گیرانه

Zero arbitrary bytecode (DEX/JVM) execution. Host processes play back deterministic vector commands without vulnerability to memory corruption, infinite loops, or malicious code injection. فاقد اجرای بایت‌کدهای اجرایی متفرقه (DEX یا JVM). سیستم میزبان تنها دستورات جبری و هندسی مشخص را ترسیم می‌کند که خطرات نشت حافظه، حلقه‌های بی‌پایان و نفوذ امنیتی را به صفر می‌رساند.

ℹ️ The Problem RemoteCompose Solves ریشه پیدایش و مشکلی که حل می‌کند

For over 15 years, Android relied on RemoteViews for cross-process UI (Widgets, Notifications, Auto). RemoteViews works via heavy Java reflection across Binder IPC, supports only a tiny whitelist of primitive views (like LinearLayout and TextView), forbids custom Canvas drawing, and cannot run fluid animations without sending full hierarchy rebuilds over IPC on every frame. RemoteCompose fixes this permanently by decoupling UI declaration from UI execution. برای بیش از ۱۵ سال، سیستم‌عامل Android برای نمایش رابط کاربری میان پروسه‌ها (ویجت‌ها، اعلان‌ها و داشبورد خودرو) بر پایه RemoteViews کار می‌کرد. RemoteViews از ریفلکشن سنگین جاوا روی Binder IPC استفاده می‌کرد، تنها فهرست محدودی از نماهای ساده را می‌پذیرفت، اجازه ترسیم آزاد Canvas را نمی‌داد و برای کوچک‌ترین انیمیشن مجبور به ارسال مجدد کل ساختار ویجت بود. RemoteCompose با تفکیک ساختاری اعلام رابط کاربری از اجرای رندرینگ این گلوگاه قدیمی را رفع کرده است.

02 System Architecture & Pipeline معماری سیستم و خط لوله پردازش داده

The RemoteCompose ecosystem in androidx.compose.remote is partitioned into three decoupled functional layers: the Creation Tier (Producer), the Binary Wire Protocol (Data Buffer), and the Player Tier (Consumer). اکوسیستم RemoteCompose در پکیج androidx.compose.remote به سه لایه کاملاً مستقل تفکیک شده است: لایه ساخت (تولیدکننده)، پروتکل باینری سیم‌کشی (Wire Protocol) و لایه پخش‌کننده (مصرف‌کننده).

flowchart TD
  subgraph Producer["1. Producer Tier (App / Cloud Server)"]
    KDSL["Kotlin Compose DSL (@RemoteComposable)"] --> RCContext["RemoteComposeContext"]
    JavaWriter["RemoteComposeWriter (Procedural API)"] --> WBuf["WireBuffer (Growable Byte Array)"]
    RCContext --> WBuf
    StateMgr["RemoteComposeState (ID Tables for Strings/Bitmaps/Paths)"] --> WBuf
  end

  subgraph Transmission["2. Wire Protocol Transmission"]
    WBuf --> RCFile["Compact Binary Payload (.rc)
OpCodes + RPN Bytecode + Deflate Compression"] RCFile -->|"Binder IPC / Network HTTP"| Transport["Transport Layer"] end subgraph Consumer["3. Player Tier (Client / Host Display)"] Transport --> CDoc["CoreDocument (Deserializer & Tree Model)"] CDoc --> OpParser["Operations Reader & DefaultVersionMap"] OpParser --> RPNVM["RPN Expression Engine (Time, Touch & Sensors)"] RPNVM --> LocalAnim["60/120 FPS Local Animation Loop"] OpParser --> LayoutEng["Layout Engine (BoxLayout, Row, Column)"] LayoutEng --> Skia["RemoteComposeCanvas / Hardware Skia Renderer"] LocalAnim --> Skia Skia --> TouchDispatch["Touch Listener & Host Action Dispatcher"] end classDef prod fill:#1e293b,stroke:#38bdf8,stroke-width:2px,color:#f8fafc; classDef trans fill:#1e293b,stroke:#818cf8,stroke-width:2px,color:#f8fafc; classDef cons fill:#1e293b,stroke:#34d399,stroke-width:2px,color:#f8fafc; class Producer prod; class Transmission trans; class Consumer cons;

1. Creation Layer (`remote-creation`) ۱. لایه ساخت (`remote-creation`)

Developers write standard declarative Compose using @RemoteComposable functions or procedural RemoteComposeWriter. Instead of producing Android Views or Compose layout nodes directly on screen, layout modifiers and canvas draws emit serialized command primitives into a WireBuffer. توسعه‌دهندگان کدهای خود را با توابع @RemoteComposable یا کلاس RemoteComposeWriter می‌نویسند. به جای ایجاد مستقیم نماها روی صفحه، تمام مادیفایرها و ترسیمات گرافیکی به شکل کدهای عملیاتی درون یک شیء WireBuffer ذخیره می‌شوند.

2. Player Layer (`remote-player`) ۲. لایه پخش‌کننده (`remote-player`)

The host environment embeds RemoteComposePlayer (a hardware-accelerated Android View FrameLayout) or remote-player-compose. It decodes operations into a CoreDocument, measures components, and paints directly to Skia / Android Canvas. محیط میزبان از کامپوننت RemoteComposePlayer (یک فریم‌لی‌آوت شتاب‌یافته سخت‌افزاری) یا ماژول remote-player-compose استفاده می‌کند. این لایه بایت‌ها را در CoreDocument واکشی کرده و مستقیماً روی بوم Skia یا Android Canvas رندر می‌کند.

03 Under the Hood: What Happens in the Background? موتور داخلی: پردازش در پس‌زمینه چگونه کار می‌کند؟

When a RemoteCompose document is transferred across process boundaries or downloaded from a cloud endpoint, the background runtime performs a rigorous multi-stage pipeline: هنگامی که یک سند RemoteCompose میان دو پروسه منتقل شده یا از سرور ابری دانلود می‌شود، موتور پس‌زمینه مراحل چندگانه و دقیقی را به ترتیب زیر طی می‌کند:

1️⃣

Header Parsing & Capability Negotiation تحلیل هدر و سنجش سازگاری

The player reads OpCode 0 (HEADER), inspecting major/minor protocol versions, canvas dimensions, screen density, scroll capabilities, and the COMPRESS flag. If compressed, the remaining stream is decompressed via fast in-memory Deflate. پخش‌کننده ابتدا دستور هدر (OpCode 0) را خوانده و نگارش پروتکل، ابعاد طراحی، تراکم پیکسلی، وضعیت اسکرول و فلگ فشرده‌سازی را بررسی می‌کند. در صورت فشرده بودن، ادامه بافر با الگوریتم سریع Deflate در حافظه RAM بازگشایی می‌شود.

2️⃣

ID Mapping & Resource Interning نگاشت شناسه‌ها و مدیریت منابع

Strings, vector paths, font faces, shaders, and bitmap textures are indexed by unique integer IDs. This guarantees that duplicate text runs or complex path geometries are encoded only once in the payload table and referenced by ID. رشته‌های متنی، مسیرهای برداری (Paths)، شیدرها و تصاویر بیت‌مپ با شناسه‌های عددی یکتا فهرست‌بندی می‌شوند. بدین ترتیب متن‌های تکراری یا بردارها تنها یک‌بار در جدول بافر نوشته شده و در بقیه نقاط با شناسه سبک ارجاع داده می‌شوند.

3️⃣

Layout Tree & Constraint Resolution ساخت درخت چیدمان و اندازه‌گیری ابعاد

Unlike primitive display lists, RemoteCompose constructs a dynamic layout hierarchy (BoxLayout, RowLayout, ColumnLayout). It executes measure passes to resolve wrap-content, match-parent, padding, and offset constraints adaptively to the host window size. برخلاف فهرست‌های ساده ترسیم، RemoteCompose یک درخت چیدمان پویا تشکیل می‌دهد و اندازه کامپوننت‌ها را با توجه به حاشیه‌ها (Padding)، آفست و اندازه پنجره دستگاه مقصد به صورت تطبیقی اندازه می‌گیرد.

4️⃣

Continuous Paint Context Execution اجرای مداوم ترسیم روی بوم گرافیکی

At render time, RemoteContext feeds transformed matrices, clipping paths, shaders, and draw calls into PaintContext. Dynamic expressions modify parameters in place each frame without invalidating or re-allocating layout trees. در زمان رندر، RemoteContext ماتریس‌های تبدیل، مسیرهای برش، شیدرها و دستورات نقاشی را به PaintContext می‌سپارد. متغیرهای پویا بدون نیاز به بازسازی کل ساختار، پارامترهای هر فریم را درجا به‌روزرسانی می‌کنند.

Kotlin RemoteComposeCreation.kt — Producer Authoring
// Authoring an interactive remote card with dynamic time and touch reactivity
@RemoteComposable
fun RemoteWeatherCard(cityName: String, tempCelsius: Float) {
    RemoteBox(
        modifier = RemoteModifier
            .fillMaxWidth()
            .height(180.rdp)
            .background(Color(0xFF10172A))
            .border(1.rdp, Color(0xFF38BDF8))
            .roundedCorners(16.rdp)
            .padding(16.rdp)
    ) {
        RemoteColumn {
            RemoteText(
                text = cityName,
                fontSize = 24.rsp,
                color = Color.White
            )
            RemoteText(
                text = "$tempCelsius °C",
                fontSize = 42.rsp,
                fontWeight = FontWeight.Bold,
                color = Color(0xFF38BDF8)
            )
            // Animated breathing indicator driven locally by Player clock!
            RemoteCanvas(modifier = RemoteModifier.size(32.rdp)) {
                val pulse = (sin(TimeVariables.ANIMATION_TIME * 0.003f) + 1f) * 8f + 8f
                drawCircle(color = Color(0xFF34D399), radius = pulse)
            }
        }
    }
}

04 RPN Math & Reactivity Engine موتور عبارات RPN و انیمیشن محلی بدون تأخیر

The single most revolutionary architectural feature of RemoteCompose is its embedded RPN (Reverse Polish Notation) Expression Engine. In traditional Remote UI (such as RemoteViews or JSON-driven frameworks), if an element needs to move, rotate, or respond to time, the host has to re-serialize and transmit a new snapshot over IPC or the network. انقلابی‌ترین نوآوری معماری در RemoteCompose، وجود موتور عبارات محاسباتی مبتنی بر نمادگذاری معکوس لهستانی (RPN) است. در رویکردهای سنتی، هر گونه حرکت یا چرخش یا واکنش به گذر زمان نیازمند محاسبه مجدد در مبدا و ارسال یک فریم یا بسته جدید از طریق IPC یا شبکه بود.

How RPN Stack Evaluation Works عملکرد پشته ارزیابی RPN

Expressions are encoded as an array of float IDs, constants, and math opcodes. For instance, the expression (TouchX + 50) * 1.5 is serialized as:

[VAR_TOUCH_X, 50.0, OP_ADD, 1.5, OP_MUL]

The Player's stack machine pops operands, applies operators in hardware CPU registers, and pushes intermediate results back without allocating heap memory.
عبارات ریاضی به شکل آرایه‌ای فشرده از شناسه‌های متغیر، مقادیر ثابت و کدهای عملیاتی ذخیره می‌شوند. برای نمونه عبارت (TouchX + 50) * 1.5 به شکل زیر در می‌آید:

[VAR_TOUCH_X, 50.0, OP_ADD, 1.5, OP_MUL]

ماشین پشته در سمت پخش‌کننده، عملوندها را با سرعت فوق‌العاده بالا و بدون درگیر ساختن حافظه Heap یا زباله‌روب محاسبه می‌کند.

Live System Variables متغیرهای زنده متصل به سخت‌افزار

RemoteCompose binds local hardware events directly to variables monitored by expressions:

  • TimeVariables.SYSTEM_TIME: Real-time wall clock milliseconds
  • TimeVariables.ANIMATION_TIME: High-precision monotonic frame delta
  • TouchVariables.TOUCH_X / Y: Real-time gesture coordinates
  • SensorVariables.ACCELEROMETER: Physical tilt and motion vectors
متغیرهای سیستمی و سخت‌افزاری مستقیماً بدون نیاز به تبادل پیام با مبدا، در متغیرهای سند به‌روزرسانی می‌شوند:
  • TimeVariables.SYSTEM_TIME: میلی‌ثانیه‌های ساعت رسمی سیستم
  • TimeVariables.ANIMATION_TIME: زمان دقیق مونوکوتیک فریم انیمیشن
  • TouchVariables.TOUCH_X / Y: موقعیت لحظه‌ای اشاره‌گر لمسی
  • SensorVariables.ACCELEROMETER: شتاب‌سنج و حسگر زاویه فیزیکی

Java AnimatedFloatExpression.java — AOSP Evaluation Core
// Inside AOSP com.android.internal.widget.remotecompose.core.operations.utilities
public float eval(RemoteContext context) {
    float[] stack = mStack;
    int sp = 0;
    for (int i = 0; i < mOps.length; i++) {
        float op = mOps[i];
        if (op >= 0 || !isOpcode(op)) {
            stack[sp++] = resolveValue(op, context);
        } else {
            int code = (int) -op;
            switch (code) {
                case OP_ADD:  stack[sp - 2] += stack[sp - 1]; sp--; break;
                case OP_SUB:  stack[sp - 2] -= stack[sp - 1]; sp--; break;
                case OP_MUL:  stack[sp - 2] *= stack[sp - 1]; sp--; break;
                case OP_DIV:  stack[sp - 2] /= stack[sp - 1]; sp--; break;
                case OP_SIN:  stack[sp - 1] = (float) Math.sin(stack[sp - 1]); break;
                case OP_COS:  stack[sp - 1] = (float) Math.cos(stack[sp - 1]); break;
                case OP_IFELSE:
                    float cond = stack[sp - 3];
                    stack[sp - 3] = (cond > 0) ? stack[sp - 2] : stack[sp - 1];
                    sp -= 2;
                    break;
            }
        }
    }
    return stack[0];
}

05 Operations & Modifiers Catalog کاتالوگ دستورات عملیاتی و مادیفایرهای چیدمان

RemoteCompose defines an exhaustive catalog of low-level drawing primitives, layout managers, and visual modifiers. Below is the authoritative mapping derived directly from the AOSP source code: فریم‌ورک RemoteCompose مجموعه‌ای جامع از دستورات سطح پایین ترسیم، چیدمان و مادیفایرهای بصری را ارائه می‌دهد. جدول زیر نقشه معتبر استخراج شده از سورس رسمی AOSP را نشان می‌دهد:

Categoryدسته‌بندی OpCode / Classکد عملیات / کلاس AOSP Parameters & Serializationپارامترها و فرمت داده Functional Descriptionشرح کاربرد و رفتار
Document 0: HEADER version, w, h, density, flags Root metadata defining dimensions, API level, and compression mode. ابرداده ریشه شامل اندازه بوم، نگارش پروتکل و وضعیت فشرده‌سازی.
Canvas Draw 42: DRAW_RECT left, top, right, bottom Draws a bounding rectangle using the currently bound PaintBundle. ترسیم مستطیل با مشخصات گرافیکی قلم (Paint) جاری.
Canvas Draw 46: DRAW_CIRCLE centerX, centerY, radius Paints a circle with radius; can bind radius to RPN animated expressions. ترسیم دایره با شعاع متغیر متصل به خروجی فرمول‌های RPN.
Canvas Draw 44: DRAW_BITMAP bitmapId, srcRect, dstRect Hardware-accelerated texture blit from interned bitmap table. ترسیم شتاب‌یافته تصویر از جدول بیت‌مپ‌های سند.
Canvas Draw 43: DRAW_TEXT_RUN textId, start, end, x, y, rtl Complex text shaping with bidirectional LTR/RTL font rendering. شکل‌دهی پیشرفته و رندر متون دوجهته LTR و RTL.
Layouts BoxLayout / Column / Row ComponentStart, Modifiers, ComponentEnd Declarative container components matching Compose UI layout paradigms. کامپوننت‌های ساختار چیدمان مطابق با ساختار کدهای Compose.
Modifiers GraphicsLayerModifier alpha, scaleX, scaleY, rotationZ GPU matrix transformations applied locally per frame without IPC traffic. تبدیلات ماتریسی کارت گرافیک (شفافیت، چرخش، مقیاس) به صورت محلی.
Interactivity ClickModifierOperation actionId, soundEffect, hapticFeedback Captures user taps, plays haptic feedback, and invokes host action listener. ثبت کلیک‌های کاربر، پخش ویبره (Haptic) و ارسال سیگنال کلیک به میزبان.

06 Real-World Industrial Use Cases کاربردهای عملی در صنعت و سیستم‌عامل

RemoteCompose is engineered to power high-scale, cross-device Android applications where native rendering performance, battery longevity, and security boundaries are paramount: فناوری RemoteCompose برای سناریوهایی طراحی شده که ترکیب سرعت فوق‌العاده رندرینگ نیتیو، بهینه‌سازی حداکثری باتری و مرزبندی‌های امنیتی اهمیت حیاتی دارند:

📱

1. Next-Gen AppWidgets & Lockscreen (SystemUI) ۱. نسل نوین ویجت‌ها و صفحه قفل اندروید (SystemUI)

Traditional AppWidgets freeze during heavy CPU loads because updating them requires starting background application processes. With RemoteCompose, the widget's UI is shipped once as a dynamic binary document; SystemUI plays back clock ticking, weather gauge swings, and fluid charts locally with zero battery drain. ویجت‌های قدیمی اندروید به دلیل نیاز به راه‌اندازی مکرر پروسه اپلیکیشن در پس‌زمینه، با لگ مواجه می‌شدند. با RemoteCompose سند ویجت تنها یک‌بار ارسال شده و انیمیشن‌های ساعت، نمودارهای زنده و انیمیشن‌های سیال توسط پروسه SystemUI بدون بیدار کردن برنامه اجرا می‌شوند.

⌚

2. Wear OS / Smartwatches (`wear/compose/remote`) ۲. ساعت‌های هوشمند Wear OS با مصرف میکرو-واتی

Running a full Android JVM and Jetpack Compose measure/layout pass on a tiny smartwatch burns battery rapidly. RemoteCompose offloads UI authoring to a paired smartphone or background service: the watch receives a pre-compiled .rc file and executes time and heart-rate animations directly in the display controller. اجرای ماشین مجازی و چیدمان کامپوز روی پردازنده کوچک ساعت هوشمند باتری را سریعاً خالی می‌کند. با RemoteCompose، موبایل یا سرویس پس‌زمینه سند را می‌سازد و ساعت بدون نیاز به پردازش سنگین کاتلین، داده‌های ضربان قلب و زمان را با حداقل مصرف انرژی نمایش می‌دهد.

🚗

3. Android Automotive OS (AAOS) & Cluster Projection ۳. خودروهای هوشمند (AAOS) و پروژکشن پشت‌آمپر

Displaying navigation arrows, media widgets, or ADAS indicators across isolated instrument clusters requires strict process sandboxing. RemoteCompose streams UI instructions across safety boundaries without risking vehicle gauge crashes. پروژکشن ویجت‌های مسیریابی و مالتی‌مدیا به صفحه کیلومترشمار دیجیتال یا هدآپ دیسپلی خودرو نیازمند ایزولاسیون صددرصدی است. RemoteCompose دستورات رابط کاربری را بدون کوچک‌ترین ریسک کرش کردن پروسه اصلی خودرو منتقل می‌کند.

☁️

4. Server-Driven UI (SDUI) & Cloud Instant Feeds ۴. رابط کاربری سمت سرور (SDUI) بدون نیاز به آپدیت استور

E-commerce, banking, and media apps can stream rich native Compose layouts directly from Go or Kotlin backend servers. Marketing campaigns and checkout layouts can be revised in real time without passing through app store reviews. سوپراپ‌ها، بانک‌ها و فروشگاه‌های بزرگ می‌توانند ویترین‌های محصول، بنرهای متحرک و فرم‌های پرداخت را مستقیماً از سمت سرور به کلاینت بفرستند و بدون نیاز به انتشار نسخه جدید در گوگل‌پلی، تغییرات را فوراً اعمال کنند.

07 Architectural Comparison Matrix ماتریس مقایسه معماری و رویکردهای Remote UI

How does RemoteCompose compare against existing Android remote UI technologies, server-driven JSON engines, and embedded WebViews? فناوری RemoteCompose در مقایسه با روش‌های قدیمی اندروید، موتورهای مبتنی بر JSON و وب‌ویوهای تعبیه‌شده چه جایگاهی دارد؟

Capability / Metricویژگی / معیار RemoteCompose RemoteViews (Legacy) JSON SDUI (DivKit/Hyperview) Embedded WebView
Authoring Paradigm Jetpack Compose DSL Legacy XML + Reflection Proprietary JSON Schemas HTML / CSS / DOM
Payload Efficiency High (Binary Bytecode ~2-8 KB) Medium (Parcelable ~15-40 KB) Medium (JSON ~25-80 KB) Very Poor (HTML/JS ~500+ KB)
Local 60/120 FPS Animation Native RPN Virtual Machine Impossible (Requires IPC loop) Limited / Keyframe-only Heavy Battery / CSS Jank
Arbitrary Vector / Canvas Full Canvas & Skia Primitives Not Supported Not Supported HTML5 Canvas (Sub-native)
Host Cold-Start Penalty Sub-millisecond (~1 ms) Moderate (~8-15 ms) Moderate (~12-25 ms) Severe (> 150-300 ms)
Security Sandboxing Hermetic (No arbitrary code) Safe (Fixed View Whitelist) Safe (Schema parser) High Attack Surface (XSS/Bridges)

08 Performance Benchmarks بنچمارک‌ها و سنجه‌های عملکرد

Empirical measurements conducted across synthetic interactive widget stress tests comparing payload size and CPU frame latency: اندازه‌گیری‌های واقعی در سناریوهای ترافیک شدید بین‌پراسی و رندر ویجت‌های تعاملی پویا:

1. Wire Payload Size (Kilobytes - Lower is Better) ۱. حجم داده انتقالی به کیلوبایت (کمتر بهتر است)

2. Frame Render Time (Milliseconds - Lower is Better) ۲. زمان رندر هر فریم به میلی‌ثانیه (کمتر بهتر است)

09 Interactive RemoteCompose Simulator & Playground شبیه‌ساز تعاملی و آزمایشگاه زنده (Live Test Lab)

Test the RemoteCompose background evaluation engine live in your browser! Adjust time speed, drag across the canvas to simulate touch input, switch math expressions, and observe the RPN stack machine and bytecode disassembly in real time. موتور محاسباتی و رندرینگ RemoteCompose را به صورت زنده در مرورگر خود آزمایش کنید! سرعت زمان را تغییر دهید، نشانگر را روی بوم بکشید تا رویدادهای لمسی شبیه‌سازی شوند و عملکرد پشته RPN و تفکیک بایت‌کدها را در لحظه مشاهده نمایید.

RemoteCompose Player Canvas (Simulated) بوم شبیه‌سازی شده پخش‌کننده RemoteCompose

Hardware Skia emulation with live RPN expression evaluation شبیه‌سازی رندر سخت‌افزاری با ارزیابی فرمول‌های RPN در زمان واقعی
Touch: (200, 130) | FPS: 60
Active Expression Preset الگوی فرمول محاسباتی فعال
Animation Speed Multiplier ضریب سرعت انیمیشن 1.0x
Live RPN Stack Machine Inspection پایش زنده وضعیت پشته ماشین RPN
Live WireBuffer Byte Stream Disassembly تفکیک جریان بایت‌های باینری WireBuffer Total: 218 Bytes
[0x00 HEADER] v0.1 w400 h260 flags=0x01 | [0x28 PAINT_VALUES] stroke=2 color=0xFF38BDF8
[0x3F THEME] dark=1 | [0x2E DRAW_CIRCLE] cx=$TIME_COS cy=$TOUCH_Y r=$CALC_RADIUS
[0x40 DRAW_ROUND_RECT] [0x2B DRAW_TEXT_RUN] id=1 "RemoteCompose Native Core"

10 RemoteCompose Ingestion & Document Server API مشخصات وب‌سرویس و API سرور اسناد ریموت کامپوز

High-performance endpoints enabling companion devices, cloud rendering microservices, and system services to stream, compile, and validate RemoteCompose binary bytecode packages into active display players. مشخصات وب‌سرویس‌ها و نقاط دسترسی اختصاصی جهت بارگذاری، کامپایل بایت‌کد و اعتبارسنجی بسته‌های باینری RemoteCompose توسط دستگاه‌های همراه، میکروسرویس‌های ابری و پردازشگرهای سیستمی.

Submit Binary RemoteCompose Render Batch ارسال بسته باینری دستورات گرافیکی ریموت

Transmits a serialized .rc binary envelope to the display controller for immediate Skia hardware rasterization and local RPN expression binding. ارسال پوسته باینری سریا‌ل‌شده .rc به کنترلر نمایشگر جهت ترسیم بی‌درنگ سخت‌افزاری بر بستر Skia و فعال‌سازی متغیرهای محاسباتی RPN.

POST /api/v2/remote-compose/render-batch

Request Parameters پارامترهای ورودی

Parameterپارامتر Typeنوع Requiredالزامی Descriptionتوضیحات Exampleنمونه
session_token string Required Cryptographic device session token (ECDSA-signed) توکن رمزشده و معتبر نشست ارتباطی دستگاه "tok_sec_9941a87b"
document_id string Required Unique identifier for active canvas buffer شناسه یکتای بافر و لایه گرافیکی فعال "doc_wear_card_01"
wire_buffer_b64 string Required Base64 encoded binary stream starting with magic bytes RCMP01 رشته Base64 از بایت‌های باینری حاوی مجیک‌بایت RCMP01 "UkNDTVAwMQAB..."
target_density_dpi integer Optional Screen pixel density (default: 320 dpi) تراکم پیکسلی نمایشگر مقصد (پیش‌فرض: ۳۲۰) 320
acceleration_profile string Optional GPU engine: SKIA_GPU, VULKAN, SOFTWARE پروفایل موتور سخت‌افزاری گرافیک "SKIA_GPU"
JSON Request Body
{
  "session_token": "tok_sec_9941a87b",
  "document_id": "doc_wear_card_01",
  "wire_buffer_b64": "UkNDTVAwMQABAAAAAAQ...",
  "target_density_dpi": 320,
  "acceleration_profile": "SKIA_GPU"
}
JSON Response (200 OK)
{
  "status": "SUCCESS",
  "document_id": "doc_wear_card_01",
  "parsed_operations": 42,
  "allocated_vram_kb": 128.4,
  "raster_latency_ms": 0.84,
  "rpn_variables_bound": 3
}

Error Responses & Status Codes کدهای خطا و پاسخ‌های وضعیت

HTTP Statusکد وضعیت Error Codeکد خطا Description & Resolutionتوضیحات و راهکار رفع خطا
400 Bad Request CORRUPTED_WIRE_FORMAT Binary magic header missing or CRC32 checksum mismatch. Re-serialize envelope. مجیک‌هدر باینری مفقود یا چک‌سام ناهمخوان است؛ بسته باینری را مجدداً ایجاد کنید.
401 Unauthorized INVALID_SESSION_AUTH Device cryptographic session signature expired or unknown. Request new session. امضای نشست معتبر نیست یا منقضی گردیده است؛ توکن نشست جدید دریافت کنید.
422 Unprocessable UNSUPPORTED_BYTECODE_VERSION RemoteCompose bytecode version exceeds display player capabilities. Target v1.2. نسخه بایت‌کد ارسالی بالاتر از نسخه پشتیبانی‌شده توسط پخش‌کننده است.
503 Unavailable GPU_ACCELERATOR_BUSY GPU command pipeline temporarily saturated. Apply exponential backoff. خط لوله رندر موقتاً اشغال است؛ ارسال را با تاخیر افزایشی تکرار نمایید.

Query Active Document Playback State & Telemetry استعلام وضعیت پخش و سنجه‌های حافظه سند

Retrieves live display statistics, active VRAM footprint, and frame execution rate for a mounted RemoteCompose canvas. دریافت آمار زنده رندر، حجم اشغال‌شده حافظه VRAM و نرخ فریم اجرایی برای لایه فعال ریموت کامپوز.

GET /api/v2/remote-compose/documents/{doc_id}/state

Query & Path Parameters پارامترهای مسیر و کوئری

Parameterپارامتر Typeنوع Requiredالزامی Descriptionتوضیحات Exampleنمونه
doc_id string Path (Required) Document identifier string شناسه سند مورد نظر در مسیر آدرس "doc_wear_card_01"
include_metrics boolean Query (Optional) Include frame latency and VRAM telemetry (default: true) درج سنجه‌های زمان رندر و حجم حافظه (پیش‌فرض: true) true
active_tier string Query (Optional) Subsystem scope: SYSTEM_UI, WEAR_OS, AUTO فیلتر زیرسیستم مصرف‌کننده "WEAR_OS"
JSON Response (200 OK)
{
  "document_id": "doc_wear_card_01",
  "playback_state": "ACTIVE_LOOPING",
  "fps_target": 120,
  "actual_fps": 119.8,
  "vram_usage_bytes": 131480,
  "ops_in_memory": 42,
  "last_render_latency_us": 840,
  "hardware_renderer": "Skia_Vulkan_Adreno"
}

Error Responses & Status Codes کدهای خطا و پاسخ‌های وضعیت

HTTP Statusکد وضعیت Error Codeکد خطا Description & Resolutionتوضیحات و راهکار رفع خطا
404 Not Found DOCUMENT_NOT_FOUND No active document buffer matching doc_id in player cache. سندی با شناسه مورد نظر در بافر فعال پخش‌کننده یافت نشد.
403 Forbidden DEVICE_ACCESS_DENIED Caller lacks permission to inspect session diagnostics. پردازش فراخوان مجوز دسترسی به سنجه‌های این نشست را ندارد.

11 Authoritative References & Standards مراجع و استانداردهای معتبر AOSP

AOSP Frameworks Base

AOSP RemoteCompose Core Engine (`com.android.internal.widget.remotecompose`)

https://android.googlesource.com/platform/frameworks/base/+/refs/heads/main/core/java/com/android/internal/widget/remotecompose/
AndroidX Compose

AndroidX Compose Remote Architecture & Wire Format (`compose/remote`)

https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-main/compose/remote/
Wear OS Architecture

Wear OS Remote Compose Engine (`wear/compose/remote`)

https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-main/wear/compose/remote/
AOSP SystemUI

Android SystemUI Keyguard & Lockscreen RemoteCompose Integration

https://android.googlesource.com/platform/frameworks/base/+/refs/heads/main/packages/SystemUI/compose/