WindowsDevicePortalWrapper icon indicating copy to clipboard operation
WindowsDevicePortalWrapper copied to clipboard

Uploading this specific JSON file to the Hololens with UploadFileAsync() crashes for unknown reason

Open gjrgj opened this issue 7 years ago • 8 comments

I have attached the file in question in a .zip.To recreate the issue, unzip the folder and try uploading the file to the Hololens with the aforementioned method.

scenes.zip

gjrgj avatar Jul 31 '17 20:07 gjrgj

What directory are you uploading it to? Or is this a HoloLens specific API?

hpsin avatar Jul 31 '17 20:07 hpsin

I'm trying to upload it to the CameraRoll directory for processing it with an application - are there restrictions on what sorts of files can exist there?

gjrgj avatar Jul 31 '17 20:07 gjrgj

Trying to upload it through the regular dev portal interface in-browser also fails but without throwing an error.

gjrgj avatar Jul 31 '17 20:07 gjrgj

Does uploading it to any other folder also fail? I cannot reproduce this on the latest desktop, mobile or IoT builds. What version of HoloLens are you using? (RS1_release?)

hpsin avatar Jul 31 '17 20:07 hpsin

Interestingly when I try to upload the file to the LocalCache folder in the specific application within LocalAppData, the upload succeeds. Could this issue have to do with permissions on public folders within the Hololens?

edit: I am using RS1_release.

gjrgj avatar Jul 31 '17 20:07 gjrgj

I apologize for so many messages, but the issue came up again. For some reason the file uploaded fine once, and now it refuses to anymore. Here is the function I'm using for upload if it helps:

/// <summary>
        /// Uploads individual files to the Hololens for loading.
        /// </summary>
        public Task UploadFile(string fileName)
        {
            Task uploadT = new Task(
                async () =>
                {
                    await portal.UploadFileAsync("LocalAppData", fileName, "LocalCache", "prospect-hololens_1.0.0.0_x86__pzq3xp76mxafg");
                    //[NonSerialized]
                    //await portal.UploadFileAsync("CameraRoll", fileName);
                });
            uploadT.Start();
            return uploadT;
        }

        /// <summary>
        /// Click handler for the uploadFiles button.
        /// </summary>
        /// <param name="sender">The caller of this method.</param>
        /// <param name="e">The arguments associated with this event.</param>
        private void UploadFiles_Click(object sender, RoutedEventArgs e)
        {
            this.ClearOutput();
            this.EnableConnectionControls(false);
            this.EnableDeviceControls(false);

            StringBuilder sb = new StringBuilder();
            Task uploadTask = new Task(
                async () =>
                {
                    sb.Append(this.MarshalGetCommandOutput());
                    sb.AppendLine("Uploading files...");
                    this.MarshalUpdateCommandOutput(sb.ToString());

                    try
                    {
                        // get all files first
                        String folderPath = @"C:\Users\georg\AppData\Local\Temp\com.irisvr.prospect\geometry";
                        string[] files = Directory.GetFiles(folderPath, "*", SearchOption.AllDirectories);

                        sb.AppendLine("Files:");
                        for(int i = 0; i < files.Length; i++)
                        {
                            Debug.WriteLine(files[i]);
                            await UploadFile(files[i]);
                            
                            //FileInfo f = new FileInfo(files[i]);
                            //Debug.WriteLine(f.Length * 12 / 100000);
                            //await Task.Delay((int)(f.Length * 12 / 100000));
                            //await Task.Delay(1000);
                            sb.Append("File " + files[i] + " uploaded successfully\n");
                        }
                        
                    }
                    catch (Exception ex)
                    {
                        sb.AppendLine("Failed to upload files.");
                        sb.AppendLine(ex.GetType().ToString() + " - " + ex.Message);
                    }
                    sb.AppendLine("Uploading complete!");
                    this.MarshalUpdateCommandOutput(sb.ToString());
                });

            Task continuationTask = uploadTask.ContinueWith(
                (t) =>
                {
                    this.MarshalEnableDeviceControls(true);
                    this.MarshalEnableConnectionControls(true);
                });

            uploadTask.Start();
        }

gjrgj avatar Jul 31 '17 20:07 gjrgj

Sorry for the delay George.

Hm, I don't know of any file permissions restrictions on CameraRoll, but don't have a HoloLens to test on. I noticed this: // to prevent hololens from locking out network IO (I don't know why this happened, but it occurred when I used to use the CameraRoll folder // and I don't want to risk it again) //FileInfo f = new FileInfo(files[i]); //Debug.WriteLine(f.Length * 12 / 100000); //await Task.Delay((int)(f.Length * 12 / 100000)); //await Task.Delay(1000); I don't know of anything in Device Portal that prevents it from handling multiple file uploads at once, but it's a possibility. I'll continue investigating. Does the workaround of not using CameraRoll unblock you?

hpsin avatar Aug 03 '17 18:08 hpsin

Hey Hirsch, no worries. Those comments are remnants from a situation that occurred several weeks ago during development and that I fixed with a factory reset - however, I don't remember if the issue was with the specific file I was trying to upload or with IO being locked out. Probably the file.

I think Device Portal handles uploading multiple files just fine, but certain files trigger it to break for unknown reasons. I would have to do extensive testing to figure out what it is about the file that breaks.

I'm currently just using a different file as a workaround, but not using CameraRoll did not unblock me for that specific file.

gjrgj avatar Aug 04 '17 14:08 gjrgj