Skip to content

Prune WebXR to reduce android binary size - #1

Merged
ckim1346 merged 2 commits into
webnnfrom
webxr
May 27, 2026
Merged

Prune WebXR to reduce android binary size#1
ckim1346 merged 2 commits into
webnnfrom
webxr

Conversation

@ckim1346

Copy link
Copy Markdown
Owner

This PR decouples Cobalt's dependency on WebXR, which is important in pruning Dawn/WebGPU. This is Step 2 of 3 to safely remove the heavy Dawn/WebGPU dependencies and achieve a significant binary size reduction on Android (~800 KB total). Pruning WebXR on top of WebNN shows an additional binary size decrease of ~278.5 KB (93,093,829 to 92,815,301 bytes), bringing total cumulative savings to ~557 KB.

Key Changes:

  1. Build Graph Pruning (GN Subtraction):
    • Subtracted //third_party/blink/renderer/modules/xr from sub_modules in modules/BUILD.gn .
    • Gated the xr dependency behind !is_cobalt in third_party/blink/renderer/modules/video_rvfc/BUILD.
    • Subtracted the xr dependency in third_party/blink/renderer/modules/webgl/BUILD.gn for Cobalt builds
    to ensure WebGL remains fully functional without WebXR.
  2. Bindings Filtering:
    • Added cobalt_webxr_exclude_patterns to bindings.gni to target v8_xr. and v8_xr_ .
    • Filtered out generated WebXR V8 bindings in bindings/modules/v8/BUILD.gn (concatenated with
    cobalt_webnn_exclude_patterns ) to prevent their compilation into libv8.a .
  3. Lightweight C++ Stubbing & Best Practices:
    • Appended WebXR stubs (V8 wrappers and C++ entry points like XRSystem::From() returning nullptr ) to
    cobalt_modules_stubs.cc .

Bug: 512589073

@github-actions

Copy link
Copy Markdown

🤖 Gemini Suggested Commit Message


Error: Could not parse a valid response from the Gemini API. Please check the API response logs in the workflow run.

💡 Pro Tips for a Better Commit Message:

  1. Influence the Result: Want to change the output? You can write custom prompts or instructions directly in the Pull Request description. The model uses that text to generate the message.
  2. Re-run the Generator: Post a comment with: /generate-commit-message

@ckim1346
ckim1346 merged commit 6c53d30 into webnn May 27, 2026
@ckim1346
ckim1346 deleted the webxr branch May 27, 2026 23:25
ckim1346 pushed a commit that referenced this pull request Jul 7, 2026
…:ThreadPool (youtube#11184)

CobaltPerformance memory measurement APIs (MeasureAvailableCpuMemory,
MeasureUsedCpuMemory, MeasureUsedSwapMemory,
MeasureReservedVirtualMemory)
were executing synchronous system metrics queries and file reads on the
Renderer thread sequence, causing UI thread stalls of up to 2.37 ms per
invocation (11.04 ms total during trace analysis).
    
This change wraps the system queries using
base::ThreadPool::PostTaskAndReplyWithResult,
ensuring system file reads run on a background thread pool without
blocking
the main Renderer message loop.

  ### Quantitative Performance Metrics (Optimization #1)
  
  1. Invocation Frequency & Call Count:
      •  MeasureUsedSwapMemory : Called 3 times during the trace period.
      •  MeasureUsedCpuMemory : Called 2 times.
      •  MeasureAvailableCpuMemory : Called 1 time.
      •  MeasureReservedVirtualMemory : Called 1 time.
      • Total synchronous calls on Renderer thread sequence: 7 calls.
  2. Main Thread Blocking Duration (CPU / IO Stall Savings):         
      •  MeasureUsedSwapMemory : 7.11 ms total (avg 2.37 ms per call).
      •  MeasureUsedCpuMemory : 1.91 ms total (avg 0.96 ms per call). 
      •  MeasureAvailableCpuMemory : 1.24 ms total (1.24 ms per call).
• MeasureReservedVirtualMemory : 0.78 ms total (0.78 ms per call).
• Total direct Renderer thread blocking time saved: 11.04 ms (over 7
invocations).
  3. Impact Summary for CL Description:
• Before Change: Every call to window.performance memory metrics / H5VCC
settings triggered synchronous system calls ( /proc file reads & system
stats) on the Renderer message loop, blocking
JavaScript execution by up to 2.37 ms per invocation (total 11.04 ms
stall during the trace).
• After Change: Memory metrics are queried off-thread via
base::ThreadPool , reducing Chrome_InProcRendererThread blocking time to
0.00 ms for memory measurement API calls.


Bug: 530222962
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant