dji-sdk / Mobile-SDK-Android

DJI Mobile SDK for Android: http://developer.dji.com/mobile-sdk/
Other
972 stars 579 forks source link

fetchFileByteData and fetchFileData fail intermittently with errors #1235

Open brien-crean opened 1 year ago

brien-crean commented 1 year ago

Intermittently I get the errors Failed to find file #XXXX and Media download result: the server aborts the downloading when trying to download the full images with fetchFileByteData and fetchFileData.

There doesn't seem to be a pattern. I have tried adding some delays between SDK calls like refreshFileListOfStorageLocation and fetchFileData / fetchFileByteData. I also tried checking the sdCardFileListState to make sure it is UP_TO_DATE before downloading.

Sometimes it works and sometimes I have to restart the app, or restart the drone and remote controller. Sometimes that doesn't even work and if I wait a few days, then I can download via the sdk. I'm not sure what is happening?

I am using DJI Mini 2 Android 13 SDK v4.16.4

Some sample code:

val mediaManager = DJISDKManager.getInstance().product.camera.mediaManager
        mediaManager?.let { mManager ->
            mManager.refreshFileListOfStorageLocation(StorageLocation.SDCARD) { djiError ->
                if (djiError != null) {
                    println(djiError)
                }
                val mediaFileList = mManager.sdCardFileListSnapshot
                mediaFileList?.let { mList ->
                    val file = mList.first()
                    println("File Name: ${file.fileName}")
                    val cachesDirectory = File(MainApplication.getContext().cacheDir.path)
                    val mediaFiles = File("$cachesDirectory/MediaFiles")
                    if (!mediaFiles.exists()) {
                        if (!mediaFiles.mkdir()) {
                            promise.reject(Exception("Failed creating MediaFiles folder."))
                        }
                    }
                    file.fetchFileData(mediaFiles, null, object : DownloadListener<String> {
                        override fun onStart() {}
                        override fun onRateUpdate(total: Long, current: Long, persize: Long) {}
                        override fun onProgress(total: Long, current: Long) {}
                        override fun onRealtimeDataUpdate(bytes: ByteArray, l: Long, b: Boolean) {}

                        override fun onSuccess(filePath: String) {
                            println("DOWNLOAD_DEBUG - File Downloaded!!!")
                        }

                        override fun onFailure(djiError: DJIError) {
                            println("DOWNLOAD_DEBUG - File Download failed ${djiError.description}")
                        }
                    })
                }
            }
        }
dji-dev commented 1 year ago

Agent comment from yating.liao in Zendesk ticket #86256:

Regarding the media download--the server aborts the downloading. This message usually appears when the camera has not entered the download mode. To resolve this, please ensure that your camera is in the correct download mode before attempting to download any media.

As for the error message "Failed to find file #XXXX," this indicates that the corresponding photo information could not be found on the device. Is it possible that your SD card has been used with different camera models in the past? After using the "refreshFileListOfStorageLocation" function, all media files should be available.

DJISDKManager.getInstance().product.camera.mediaManager -- I would recommend that you convert the product to aircraft before getting the camera, because it does affect the effectiveness of use.

If you are still unable to locate the missing files, please let me know and I will be happy to assist you further.

°°°

brien-crean commented 1 year ago

Thanks for your help @dji-dev. I have verified that the camera is in media download mode, but I still get the error media download--the server aborts the downloading.

I am certain that the file exists when I get the error Failed to find file #XXXX. Because if I restart the drone and RC multiple times I am eventually able to retrieve the file. As you can see in my code I am running refreshFileListOfStorageLocation before attempting to retrieve the file.

Casting the product instance to Aircraft does not resolve the issue unfortunately. The only thing that helps is restarting the drone and remote controller. But this solution is not very reliable. Sometimes it does not work at all.

I see similar issues in this repository related to the MediaManager class https://github.com/dji-sdk/Mobile-SDK-Android/issues/1188 https://github.com/dji-sdk/Mobile-SDK-Android/issues/1183

I see a comment from @DJI-William in https://github.com/dji-sdk/Mobile-SDK-Android/issues/1188

We do find out sometimes you cannot refresh and read the media files properly on Mini 2 now. Known issues. It happens sometimes, it can return normal when restart the app. We will solve this issue on 4.16.5 on December.

Is there a planned update to version 4.16.5 with some fixes for the media manager class?

dji-dev commented 1 year ago

Agent comment from yating.liao in Zendesk ticket #86256:

Regarding the issue of not being able to access media files on the MINI 2, we will fix it in the next version. We have recently been able to reproduce the issue and our development team has already submitted the fix for this problem.

If you have also encountered a file named DJI_0000.jpg, then it should be the same issue.

°°°

brien-crean commented 1 year ago

@dji-dev thank you, thats fantastic news! May I ask, when is the next version scheduled to be released?

dji-dev commented 12 months ago

Agent comment from yating.liao in Zendesk ticket #86256:

At the moment, we are unable to determine the release schedule for MSDK V4.17 as there are still some unresolved issues with this version.

°°°

brien-crean commented 12 months ago

Thanks for letting me know! I'm looking forward to this update!

dji-dev commented 12 months ago

Agent comment from yating.liao in Zendesk ticket #86256:

I'm glad I could help you.

°°°

brien-crean commented 11 months ago

Pulling photos from camera may occasionally fail on DJI Mini 2: Fixed

@dji-dev I tried the branch sdk_releases/4.17-alpha with a two different Mini 2s but the image download issue still remains unfortunately. I tried both fetchFileData and fetchFileByteData and had the same issue Failed to find file #XXXX

Do you know if this issue is still being worked on?

Thanks

brien-crean commented 10 months ago

@dji-dev any update on a release for 4.17?

I tried the 4.17-alpha (4.17-a1) branch but it did not fix this issue.

fetchFileByteData and fetchFileData still throw errors

Your help would be much appreciated!