Adobe-Runtime-Support icon indicating copy to clipboard operation
Adobe-Runtime-Support copied to clipboard

"StorageVolumeInfo.storageVolumeInfo.getStorageVolumes()" lets app hang when network drive is not reachable

Open 2jfw opened this issue 3 years ago • 5 comments

Using StorageVolumeInfo.storageVolumeInfo.getStorageVolumes() lets app hang when a network drive is not reachable.

It always takes around 20 seconds for the timeout to happen. I would assume that the method is not "async" similar to several methods of the File class where specific async counterparts exist. @ajwfrost: Can you confirm this? Is this working as intended and if so, would it be possible for you to implement an async method?

Enviroment: Windows 10, AIR 33.1.1.795

Network Drives

2jfw avatar Jun 28 '22 14:06 2jfw

Any possibility you could check on this briefly?

2jfw avatar Sep 29 '22 10:09 2jfw

Yes this is an issue with the Win32 function taking a long time, and we're just in some synchronous code.. https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getvolumeinformationa

So we can look at adding a getStorageVolumesAsync() option, I guess we would also then need a new event that can be dispatched when it completes that would contain the list of StorageVolume objects; or we could dispatch multiple StorageVolumeChangeEvent objects as/when each volume has been identified (with a new event type as well as the mount/unmount ones, e.g. storageVolumeDiscovered..?)

Either that, or we add a property to the StorageVolumeInfo class that is just the list of latest known volumes, which is null until getStorageVolumes() or getStoreVolumesAsync() is called, and is then populated by those functions (synchronously in the existing API, and asynchronously in the new API, and we just dispatch a complete event when the async version has finished..)?

Different options for this one, please let me know what sort of approach you think makes more sense!

thanks

ajwfrost avatar Sep 29 '22 13:09 ajwfrost

Thanks for getting back on this! We would prefer the complete event for the async approach :)

2jfw avatar Sep 29 '22 14:09 2jfw

So if we added a currentVolumes property and a new API, we could support a flow like:

// add event listener for when we get the volumes
StorageVolumeInfo.storageVolumeInfo.addEventListener(Event.COMPLETE, function(e:Event):void {
    // get the latest volumes
    var volumes:Vector.<StorageVolume> = StorageVolumeInfo.storageVolumeInfo.currentVolumes;
    for (var i:int = 0; i < volumes.length; i++)
    {
        var volume:StorageVolume = volumes[i];
        trace("nativePath:", volume.rootDirectory.nativePath);
        trace("fileSystemType:", volume.fileSystemType);
        trace("isRemovable:", volume.isRemovable);
        trace("isWritable:", volume.isWritable);
        trace("drive:", volume.drive);
        trace("name:", volume.name);
    }
});
// request the volumes asynchronously
StorageVolumeInfo.storageVolumeInfo.getStorageVolumesAsync();

ajwfrost avatar Sep 29 '22 14:09 ajwfrost

This would be perfect :) thanks for the consideration!

2jfw avatar Sep 29 '22 15:09 2jfw

@ajwfrost Is there any update on this feature?

2jfw avatar May 26 '23 09:05 2jfw

Hi @2jfw .. I've just been looking for this. Our internal tracker shows that this was done, and our AS3 documentation also shows it as completed: https://airsdk.dev/reference/actionscript/3.0/flash/filesystem/StorageVolumeInfo.html#getStorageVolumesAsync()

But I don't see any mention of it in https://airsdk.harman.com/release_notes !

So, looking at the code, there is an implementation of this which should be platform-generic, using a background thread within the StorageVolumeInfo glue code to populate the currentVolumes list when it dispatches the complete event.

In other words -> I think this is implemented, but I'm afraid we somehow missed it off the release notes!

Please have a try...!

thanks

ajwfrost avatar May 26 '23 09:05 ajwfrost

@ajwfrost Sounds good :) I can see in the IDE, that the StorageVolumeInfo has that function. I will try it out and report back - many thanks 👍

2jfw avatar May 26 '23 09:05 2jfw

Reporting back, that it is working as expected. Many thanks again!

2jfw avatar May 26 '23 10:05 2jfw

Okay great! thanks for confirming. I will see whether we can retrospectively inject a new release note for 50.0 into the database so that it at least appears on the release_notes page!

ajwfrost avatar May 26 '23 10:05 ajwfrost