Skip to content

Conversation

@riderx
Copy link
Member

@riderx riderx commented Nov 28, 2025

Test PR creation

Summary by CodeRabbit

  • New Features
    • Added optional JavaScript profiling configuration support for Android applications

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 28, 2025

Walkthrough

This PR adds support for JavaScript profiling configuration across the Capacitor Android platform. A new jsProfilingEnabled feature flag is introduced in the configuration layer, threaded through Bridge initialization, and used to conditionally set a Document-Policy header in WebViewLocalServer responses for profiling support.

Changes

Cohort / File(s) Summary
Configuration Layer
android/capacitor/src/main/java/com/getcapacitor/CapConfig.java, cli/src/declarations.ts
Introduces jsProfilingEnabled configuration flag with default value false. CapConfig adds private field, getter method isJsProfilingEnabled(), Builder setter setJsProfilingEnabled(boolean), and JSON deserialization from android.jsProfilingEnabled. TypeScript declarations updated to include optional jsProfilingEnabled?: boolean property in CapacitorConfig.android block.
Server Implementation
android/capacitor/src/main/java/com/getcapacitor/Bridge.java, android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java
Bridge reads jsProfilingEnabled from config and passes it to WebViewLocalServer constructor. WebViewLocalServer constructor signature extended to accept the flag; when enabled, creates custom headers containing Document-Policy: js-profiling and passes them to PathHandler initialization.

Sequence Diagram

sequenceDiagram
    actor Init as Initialization
    participant Config as CapConfig
    participant Bridge as Bridge
    participant WebServer as WebViewLocalServer
    participant PathHandler as PathHandler

    Init->>Config: Read jsProfilingEnabled from config
    Config-->>Init: Return jsProfilingEnabled (bool)
    Init->>Bridge: Initialize with config
    Bridge->>Config: Call isJsProfilingEnabled()
    Config-->>Bridge: Return jsProfilingEnabled value
    Bridge->>WebServer: new WebViewLocalServer(..., jsProfilingEnabled)
    alt jsProfilingEnabled == true
        WebServer->>WebServer: Create customHeaders<br/>with Document-Policy: js-profiling
        WebServer->>PathHandler: Initialize with customHeaders
    else jsProfilingEnabled == false
        WebServer->>PathHandler: Initialize without customHeaders
    end
    PathHandler-->>WebServer: PathHandler ready
    WebServer-->>Bridge: WebViewLocalServer initialized
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

The changes follow a straightforward pattern for adding a configuration feature flag: new field with getter/setter, Builder integration, JSON deserialization, and conditional header injection. All modifications are consistent and boilerplate-oriented with no complex logic or interdependencies requiring special attention.

Poem

🐰 A profile flag hops into the code,
Through configs and bridges, it finds its road,
JS profiling now can trace and play,
With headers set the document-policy way! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title references a specific upstream PR (ionic-team#8263) and indicates a synchronization action, which aligns with the changes that introduce a jsProfilingEnabled feature flag across multiple files (Bridge, CapConfig, WebViewLocalServer, and declarations).
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sync/upstream-pr-8263

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
android/capacitor/src/main/java/com/getcapacitor/CapConfig.java (1)

57-57: jsProfilingEnabled config flag is consistently wired through CapConfig and Builder

  • The new jsProfilingEnabled field, its JSON deserialization from android.jsProfilingEnabled, the isJsProfilingEnabled() getter, and the Builder field + setJsProfilingEnabled(boolean) are all consistent and default to false.
  • This matches the CLI config surface (android.jsProfilingEnabled) and how Bridge/WebViewLocalServer consume the flag.

Looks good as‑is; just ensure this new option is reflected in any external configuration docs or release notes you maintain.

Also applies to: 185-185, 291-291, 388-390, 592-592, 697-700

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4c7c126 and 209b6b2.

📒 Files selected for processing (4)
  • android/capacitor/src/main/java/com/getcapacitor/Bridge.java (1 hunks)
  • android/capacitor/src/main/java/com/getcapacitor/CapConfig.java (6 hunks)
  • android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java (3 hunks)
  • cli/src/declarations.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
android/capacitor/src/main/java/com/getcapacitor/CapConfig.java (1)
android/capacitor/src/main/java/com/getcapacitor/util/JSONUtils.java (1)
  • JSONUtils (10-166)
🪛 GitHub Actions: CI
android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java

[error] 1-1: Prettier formatting check failed. Run 'prettier --write' to fix code style issues in this file.

🔇 Additional comments (3)
cli/src/declarations.ts (1)

300-310: Android jsProfilingEnabled config surface and docs look consistent

The new android.jsProfilingEnabled?: boolean flag and its documentation align with the native config key and behavior (toggling the Document-Policy: js-profiling header). Just make sure the @since 8.0.0 tag matches the actual release version for this branch.

android/capacitor/src/main/java/com/getcapacitor/Bridge.java (1)

275-277: Clean propagation of jsProfilingEnabled into WebViewLocalServer

Using config.isJsProfilingEnabled() here and passing it to the extended WebViewLocalServer constructor is consistent with the new config plumbing and preserves existing behavior when the flag is left at its default false.

android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java (1)

66-67: Based on my verification, I can now provide the rewritten review comment:


jsProfilingEnabled wiring and header injection are correct; fix Prettier formatting for Java files

The new jsProfilingEnabled flag is properly threaded through WebViewLocalServer's constructor (line 137) and correctly used in createHostingDetails() to conditionally add Document-Policy: js-profiling to response headers when enabled. The single instantiation in Bridge.java:276 uses the correct 6-argument signature. Default behavior remains unchanged when disabled.

Action required:

The CI lint job runs Prettier on Java files via prettier-plugin-java. Run npm run fmt to auto-format all files, or specifically:

npm run prettier -- --write android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java

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.

2 participants