In case iOS Device is detached, the IOSDevice instance is kept alive. The reason is the handler for device logs, that IOSDevice passes to iOSDeviceOperations.
As iOSDeviceOperations is still alive, the IOSDevice instance is also alive. Reattaching the same device will cause duplicate logs. Detaching and attaching it again will lead to additional logs.
In order to fix the issue, convert iOSDeviceOpertations to event emitter and emit event when there's data for logging. Each IOSDevice will add handler for the event and will do its logic.
In case device is detached (i.e. DeviceLost event is fired in DevicesService), call a newly added method to the specific IDevice instance. It's purpose is to clean the used resource.
For iOS device, this method will remove the handler for devceLogData event of iOSDeviceOperations.
In case iOS Device is detached, the
IOSDevice
instance is kept alive. The reason is the handler for device logs, thatIOSDevice
passes toiOSDeviceOperations
. AsiOSDeviceOperations
is still alive, theIOSDevice
instance is also alive. Reattaching the same device will cause duplicate logs. Detaching and attaching it again will lead to additional logs.In order to fix the issue, convert
iOSDeviceOpertations
to event emitter and emit event when there's data for logging. EachIOSDevice
will add handler for the event and will do its logic. In case device is detached (i.e.DeviceLost
event is fired inDevicesService
), call a newly added method to the specificIDevice
instance. It's purpose is to clean the used resource. For iOS device, this method will remove the handler fordevceLogData
event ofiOSDeviceOperations
.