Skip to content

Conversation

@gmegidish
Copy link
Member

@gmegidish gmegidish commented Nov 26, 2025

Summary by CodeRabbit

  • Refactor

    • Optimized offline Android virtual device discovery for improved reliability
    • Updated iOS simulator discovery mechanism
    • Added performance timing metrics to device discovery process
  • Chores

    • Updated dependencies to support device discovery enhancements

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

@coderabbitai
Copy link

coderabbitai bot commented Nov 26, 2025

Warning

Rate limit exceeded

@gmegidish has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 5 minutes and 19 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between fde5cfd and b231ccc.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • devices/common.go (3 hunks)
  • devices/simulator.go (4 hunks)
  • go.mod (2 hunks)

Walkthrough

The PR shifts two device discovery mechanisms from live command-line queries to filesystem-based configuration parsing: AVD discovery now reads .ini configuration files instead of parsing avdmanager output, and iOS simulator discovery reads device.plist files instead of xcrun JSON output. Device discovery timing instrumentation is added to measure per-category durations.

Changes

Cohort / File(s) Summary
AVD Filesystem Configuration
devices/avd.go
Replaces avdmanager output parsing with direct .ini file reading from ~/.android/avd/ directory. Adds getAVDDetails() function to glob .ini files, load configuration, and derive AVD metadata. Introduces convertAPILevelToVersion() mapping and apiLevelToVersion data for offline API-to-version translation. Removes Path, Target, and BasedOn fields from AVDInfo struct. Adds imports: os, filepath, gopkg.in/ini.v1.
iOS Simulator Filesystem Discovery
devices/simulator.go
Replaces JSON-based xcrun simulator discovery with filesystem-based approach reading device.plist files from CoreSimulator Devices directory. Introduces devicePlist struct for plist unmarshaling. Implements state mapping (plist int to human-readable strings: 3 = "Booted", others = "Shutdown"). Maintains []Simulator return type with filesystem-sourced data.
Device Discovery Timing Instrumentation
devices/common.go
Adds per-phase timers in GetAllControllableDevices() to track Android, offline Android, iOS real devices, and iOS simulator discovery durations. Introduces counters and duration trackers with verbose logging reporting category counts and timings. Adds time package import.
Dependency Updates
go.mod
Moves howett.net/plist from indirect to direct dependency (v0.0.0-20200419221736-3b63eb3a43b5). Adds explicit requirement: gopkg.in/ini.v1 v1.67.0.

Sequence Diagram

sequenceDiagram
    autonumber
    participant client as Caller
    participant common as GetAllControllableDevices()
    participant avd as getAVDDetails()
    participant fs as Filesystem (.ini)
    participant sim as getSimulators()
    participant plist as device.plist
    
    client->>common: Request all devices (includeOffline)
    common->>common: Start total timer
    
    rect rgb(200, 220, 240)
    note over common,avd: Android Device Discovery
    common->>common: Start Android phase timer
    common->>avd: Get offline AVD details
    avd->>fs: Glob *.ini files in ~/.android/avd/
    fs-->>avd: List of .ini files
    loop For each .ini file
        avd->>fs: Read .ini (path, display name, target)
        fs-->>avd: Config data
        avd->>fs: Read config.ini from avd directory
        fs-->>avd: API level, device info
    end
    avd->>avd: Convert API level to version
    avd-->>common: AVDInfo list
    common->>common: Record Android duration & count
    end
    
    rect rgb(240, 220, 200)
    note over common,sim: iOS Simulator Discovery
    common->>common: Start simulator phase timer
    common->>sim: Get simulators via plist
    sim->>fs: Iterate CoreSimulator Devices directory
    loop For each device directory
        sim->>fs: Read device.plist
        fs-->>sim: Plist data
        sim->>plist: Unmarshal to devicePlist struct
        sim->>sim: Map state (3=Booted, other=Shutdown)
    end
    sim-->>common: Simulator list
    common->>common: Record simulator duration & count
    end
    
    common->>common: Compute total duration
    common->>common: Log per-category metrics & counts
    common-->>client: All devices with timing metadata
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

  • devices/avd.go: Significant refactoring with new ini-based parsing logic, new helper functions, struct field removals affecting the public API, and data transformation for API level to version mapping warrant careful verification.
  • devices/simulator.go: Plist unmarshaling logic and state mapping require validation of correctness; transition from JSON to plist data sources needs verification.
  • Cross-file impact: Changes to AVDInfo struct fields affect avd.go and common.go integration; timing instrumentation spans multiple functions in common.go and needs to preserve existing behavior.
  • Dependency updates: Verify compatibility of new ini and plist library versions with existing codebase.

Poem

🐰 No more commands we chase,
Files whisper AVD grace,
Plists speak their secret song,
Filesystem guides us along,
Fast discovery, offline and true!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: replacing xcrun-based simulator discovery with filesystem parsing eliminates the 'simctl list' call, improving performance.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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: 1

🧹 Nitpick comments (1)
devices/avd.go (1)

109-112: Consider using AVD name as fallback when displayName is empty.

If avd.ini.displayname is not set in config.ini (which can happen for older or manually created AVDs), the entire AVD is skipped. This could cause valid AVDs to not appear in the offline device list.

 		displayName := configData.Section("").Key("avd.ini.displayname").String()
 		if displayName == "" {
-			continue
+			// fallback to avd name if displayname is not set
+			displayName = strings.TrimSuffix(filepath.Base(iniFile), ".ini")
 		}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3470934 and fde5cfd.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (4)
  • devices/avd.go (2 hunks)
  • devices/common.go (3 hunks)
  • devices/simulator.go (4 hunks)
  • go.mod (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
devices/common.go (3)
utils/logger.go (1)
  • Verbose (19-23)
devices/ios.go (1)
  • ListIOSDevices (89-107)
devices/simulator.go (1)
  • GetSimulators (124-175)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: lint
🔇 Additional comments (7)
devices/common.go (1)

62-139: Well-structured timing instrumentation for performance monitoring.

The timing implementation correctly captures per-phase durations and device counts without affecting the core device discovery logic. The verbose logging at the end provides useful diagnostics for identifying performance bottlenecks.

devices/simulator.go (4)

36-42: LGTM - devicePlist struct correctly maps plist fields.

The struct properly uses plist tags to map the device.plist fields.


123-134: Filesystem-based discovery is a good performance optimization.

Reading directly from the filesystem avoids spawning xcrun simctl list processes. The error handling correctly surfaces directory access issues while the function gracefully handles missing or inaccessible device directories.


143-154: Silent error handling for individual devices is appropriate.

Skipping devices without device.plist or with invalid plist data is the right approach - these are likely incomplete/corrupted simulator instances that shouldn't block discovery of valid simulators.


156-162: I'll help you verify this review comment about incomplete state mapping in the simulator. Let me start by examining the relevant code sections.
<function_calls>

find . -name "simulator.go" -type f | head -20

</function_calls>
<function_calls>

wc -l devices/simulator.go 2>/dev/null || echo "File not found, searching..."

</function_calls>
<function_calls>

cat -n devices/simulator.go | sed -n '150,170p'

</function_calls>
<function_calls>

cat -n devices/simulator.go | sed -n '410,420p'

</function_calls>
<function_calls>

rg -n "State\s*=|state\s*=" devices/simulator.go -C 2

</function_calls>

devices/avd.go (2)

20-47: Comprehensive API level mapping for offline AVD version display.

The mapping covers API levels 21-36 (Android 5.0 to 16.0), which is a good range. The fallback to return the API level as-is handles future/unknown API levels gracefully.


71-129: Filesystem-based AVD discovery is a solid performance improvement.

Reading INI files directly avoids the overhead of spawning avdmanager and parsing its textual output. The implementation correctly handles the two-level INI structure (.iniconfig.ini) and gracefully skips problematic entries with verbose logging.

@gmegidish gmegidish merged commit 3b4793d into main Nov 26, 2025
8 checks passed
@gmegidish gmegidish deleted the fix-optimize-simctl-list-online-devices branch November 26, 2025 15:30
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