Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 4, 2025

MTDeviceCreateDefault() returns a device that may already exist in the list from MTDeviceCreateList(), causing duplicate callback registration and inflated device counts.

Changes

  • Track registered devices in a Set<UnsafeMutableRawPointer> during startup
  • Skip default device registration if already present in the set
  • Add debug logging when duplicate is detected
var registeredDevices: Set<UnsafeMutableRawPointer> = []

// Register devices from list
for device in deviceList {
    registeredDevices.insert(device)
    // ... register callback
}

// Only register default if not already tracked
if let defaultDevice = getDefaultDevice(),
   !registeredDevices.contains(defaultDevice) {
    // ... register callback
}

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: NullPointerDepressiveDisorder <96403086+NullPointerDepressiveDisorder@users.noreply.github.com>
Copilot AI changed the title [WIP] Update Sentry implementation based on feedback from PR #4 Fix double registration of default multitouch device Dec 4, 2025
@NullPointerDepressiveDisorder NullPointerDepressiveDisorder marked this pull request as ready for review December 4, 2025 04:06
Copilot AI review requested due to automatic review settings December 4, 2025 04:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where MTDeviceCreateDefault() could return a device pointer already present in the list from MTDeviceCreateList(), causing duplicate callback registration and inflated device counts.

Key Changes:

  • Introduced a Set<UnsafeMutableRawPointer> to track registered device pointers during startup
  • Added duplicate detection before registering the default device
  • Added debug logging when a duplicate is detected

@NullPointerDepressiveDisorder NullPointerDepressiveDisorder merged commit 9055297 into sentry Dec 4, 2025
7 checks passed
@NullPointerDepressiveDisorder NullPointerDepressiveDisorder deleted the copilot/sub-pr-4 branch December 4, 2025 04:15
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