Skip to content

fix(ios): use pointer receivers on IOSDevice to stop copying its mutex - #357

Open
gmegidish wants to merge 1 commit into
mainfrom
fix/ios-device-copylocks
Open

fix(ios): use pointer receivers on IOSDevice to stop copying its mutex#357
gmegidish wants to merge 1 commit into
mainfrom
fix/ios-device-copylocks

Conversation

@gmegidish

@gmegidish gmegidish commented Aug 24, 2026

Copy link
Copy Markdown
Member

Fixes all 30 govet copylocks findings. IOSDevice contains a sync.Mutex (protecting the port forwarders and deviceKit state), but 28 methods used value receivers — every call copied the struct, mutex included, so the lock never actually guarded shared state. The constructor and ListIOSDevices also copied the struct by value.

Changes:

  • All IOSDevice methods now use *IOSDevice receivers (matching StartAgent/StartScreenCapture, which already did)
  • getDeviceInfo returns *IOSDevice; ListIOSDevices returns []*IOSDevice
  • GetDeviceInfoList in common.go appends the pointers directly instead of &iosDevices[i]
  • Two tests updated to use pointer values

Verified: go build ./..., go vet ./..., go test ./... all pass; golangci-lint govet count is 0 (was 30).

Summary by CodeRabbit

  • Improvements

    • Improved consistency when discovering and managing connected iOS devices.
    • Updated iOS device operations to behave more reliably across physical devices and simulators.
    • Preserved existing validation, supported actions, and error handling for device interactions.
  • Tests

    • Expanded coverage for iOS device capabilities and simulator activity restrictions.

@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ca06742d-3eda-4762-a2f9-3fcaee4ea368

📥 Commits

Reviewing files that changed from the base of the PR and between 0545812 and 9fd2aee.

📒 Files selected for processing (1)
  • devices/ios.go

Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.


📝 Walkthrough

Walkthrough

The change converts IOSDevice construction, discovery, and methods to pointer-based usage. It updates aggregate device handling and tests for the pointer method set. Existing delegated operations and validation behavior remain unchanged.

Changes

iOS pointer-based device model

Layer / File(s) Summary
Pointer-based discovery and aggregation
devices/ios.go, devices/common.go
iOS device construction and discovery now return pointers. Failed construction paths return nil. Aggregate device handling appends iOS device values.
Pointer receivers and tests
devices/ios.go, devices/animations_test.go, devices/simulator_activity_test.go
IOSDevice control, metadata, app, input, source, installation, tunnel, and orientation methods now use pointer receivers. Tests use pointer-based calls and assertions.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 9fd2a

The PR changes IOSDevice handling to use pointers so its mutex is not copied, with related list and test updates. It is merge-ready after normal checks and review, with no actionable merge-blocking risk remaining.

Suggested reviewers: hakanor

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: switching IOSDevice methods to pointer receivers to prevent mutex copying.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ios-device-copylocks

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

Comment thread devices/ios.go Fixed
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