Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application freezes after deleting files from device #53

Closed
snowy-owll opened this issue Jul 9, 2021 · 4 comments
Closed

Application freezes after deleting files from device #53

snowy-owll opened this issue Jul 9, 2021 · 4 comments

Comments

@snowy-owll
Copy link

Library version: 1.8.0.0 (from Nuget, but tried building the latest version from sources too)
Operating system: Windows 7/10
.NET Framework: 4.5

Made the minimum number of operations:

  • Getting connected devices
  • Connection to device
  • Subscription to device events
  • Display a list of files from the folder I need on the device
  • Deleting each of these files

After the last step, the application completely freezes until I unplug the device (tried different phones, the behaviour is the same). Moreover, if I try to open Explorer, it will freeze too. If there are a lot of files, then the program manages to delete some of them.

Because of what it can be and is it possible to fix it somehow?

Thank you!

@snowy-owll
Copy link
Author

snowy-owll commented Jul 13, 2021

Most likely the problem is not with your library. I tried to do file deletion in C++ and through the library generated by Visual Studio. It still freezes. Maybe you have any idea why this might be happening?
UPD After several experiments, I found that the more files on the device, the more freezing after deletion. If there are about 2000 files on the device, the freeze may take about 10 seconds.

@Bassman2
Copy link
Owner

This library is only a .NET wrapper for the windows MTP COM component. If this component neends a lot of time for the delete the library is waiting. You can try to get a list with all files and use a loop to delete each file with a single call. So you can show a progress bar.

@snowy-owll
Copy link
Author

In fact, that's what I did. But after the first or second removal, the COM object hangs. The freeze time depends on the number of files on the phone. It is even less if you use the generated DLL to access a COM object. But if you delete it through Explorer, then everything is deleted normally. And it most likely uses the same API, since it also hangs up to make an uninstallation from the program.
Hanging can reach about 10-20 seconds with 2-3 thousand files on the phone. Which is very inconvenient. I thought at the beginning that it was in the library, but after some experiments, I realized that it was in the COM object. And it doesn't matter what language to use it through. And freezes happen regardless of the system or phone.
Unfortunately, I do not have enough knowledge to figure out what happens inside the component during file deletion. But can you tell me which way to look?

@Bassman2
Copy link
Owner

After deleting a file the underlying Windows MTP library needs a verly long time to update the cache.
Retry with version 1.10 and disabled cache.

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

No branches or pull requests

2 participants