tidev / node-ios-device

Queries connected iOS devices and installs apps
Other
122 stars 37 forks source link

.trackDevices() gets triggered on unlikely events #34

Closed dragonstone071 closed 7 years ago

dragonstone071 commented 7 years ago

As per documentation:

trackDevices() Continuously retrieves an array of all connected iOS devices. Whenever a device is connected or disconnected, the devices event is emitted.

tractDevices()'s callback should only be triggered when new devices are connected or current devices get disconnected. But I have observed this being called on unlikely events such as, starting QuickTime video recording on a device.

Steps To Reproduce

iosDevice .trackDevices() .on('devices', function (devices) { console.log('Connected devices:'); console.log(devices); }) .on('error', function (err) { console.error('Error!', err); });


- Start quickTime video recording for the device (QuickTimePlayer -> File -> New Movie Recording -> Select Device)

`.on('devices')` callback will be triggered which is not expected here. 
cb1kenobi commented 7 years ago

@dragonstone071 Thanks for reporting this. I have added this to my radar, but may be a while before I can take a look. Stay tuned. Thanks!

cb1kenobi commented 7 years ago

So, I took a look at this and indeed when you start recording from the device, the 'devices' event is triggered.

However, in my tests, it fires twice: once to show the device has been disconnected and once showing it has been reconnected. While this behavior is unexpected, it's happening inside the MobileDevice framework and is outside the control of node-ios-device.

It's perhaps outside the scope of node-ios-device to delay the 'device' event to protect against this. Given that the list of devices does eventually become correct, I'm going to close this ticket. You can always code around this in your app by using a modified debounce function.