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

[Bug] PutStreamAsync is never completed if there is no internet connection #1037

Open
dacodelaac opened this issue Apr 29, 2021 · 9 comments

Comments

@dacodelaac
Copy link

  • Unity editor version: 2019.4.21f1
  • Firebase Unity SDK version: 7.1.0
  • Source you installed the SDK: .unitypackage
  • Problematic Firebase Component: Storage
  • Other Firebase Components in use: Auth
  • Additional SDKs you are using:
  • Platform you are using the Unity editor on: Windows
  • Platform you are targeting: iOS, Android
  • Scripting Runtime: Mono and IL2CPP

I am using Firebase Storage and currently having an issue using PutStreamAsync when there is no internet connection. It seems like the task will never complete, even though I reduced MaxUploadRetryTime to 1 second or got the internet connection back. Task.Status is always WaitingForActivation

var task = storageReference.PutStreamAsync(ms, new MetadataChange()
{
    CustomMetadata = GetMetaData()
}, null, CancellationTokenSource.Token);

Editor log:

ApplicationException: GetFutureStatus(handle) == kFutureStatusPending
Rethrow as ApplicationException: backing->status != kFutureStatusComplete
Firebase.Storage.StorageReferenceInternal.PutBytesUsingMonitorControllerAsync (System.IntPtr buffer, System.UInt32 buffer_size, Firebase.Storage.MetadataInternal metadata, Firebase.Storage.MonitorControllerInternal monitor_controller) (at Z:/tmp/tmp.0Ryilsblb3/firebase/storage/client/unity/proxy/StorageReferenceInternal.cs:148)
Firebase.Storage.StorageReference.PutBytesUsingMonitorControllerAsync (System.IntPtr buffer, System.UInt32 bufferSize, Firebase.Storage.MetadataInternal metadata, Firebase.Storage.MonitorControllerInternal monitorController, System.Threading.CancellationToken cancellationToken) (at Z:/tmp/tmp.0Ryilsblb3/firebase/storage/client/unity/proxy/StorageReference.cs:276)
Firebase.Storage.StorageReference.PutBytesUsingCompletionSourceAsync (System.Byte[] bytes, Firebase.Storage.MetadataChange customMetadata, System.IProgress`1[T] progressHandler, System.Threading.CancellationToken cancelToken, System.Uri previousSessionUri, System.Threading.Tasks.TaskCompletionSource`1[TResult] completionSource) (at Z:/tmp/tmp.0Ryilsblb3/firebase/storage/client/unity/proxy/StorageReference.cs:309)
Firebase.Storage.StorageReference <PutStreamAsync>c__AnonStorey7.<>m__0 () (at Z:/tmp/tmp.0Ryilsblb3/firebase/storage/client/unity/proxy/StorageReference.cs:457)
System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.Threading.ThreadHelper.ThreadStart () (at <eae584ce26bc40229c1b1aa476bfa589>:0)
UnityEngine.<>c:<RegisterUECatcher>b__0_0(Object, UnhandledExceptionEventArgs)

@dacodelaac dacodelaac changed the title [Bug] [Bug] PutStreamAsync is never completed if there is no internet connection Apr 29, 2021
@vimanyu
Copy link
Contributor

vimanyu commented Apr 29, 2021

Hi,
Thanks for creating this issue. Could you verify if this is reproducible in the Unity quickstart example for storage?

@vimanyu vimanyu added needs-attention Need Googler's attention and removed new New issue. type: question labels Apr 29, 2021
@paulinon paulinon added needs-info Need information for the developer and removed needs-attention Need Googler's attention labels Apr 30, 2021
@dacodelaac
Copy link
Author

@vimanyu Last time I checked, storage example still has this issue

@google-oss-bot google-oss-bot added needs-attention Need Googler's attention and removed needs-info Need information for the developer labels May 5, 2021
@DellaBitta
Copy link
Contributor

Hi @dacodelaac,

For our reproduction puposes, could you tell us which platform(s) this occurs on?

Thanks!

@DellaBitta DellaBitta added needs-info Need information for the developer and removed needs-attention Need Googler's attention labels May 5, 2021
@dacodelaac
Copy link
Author

@DellaBitta, I was using Unity Editor 2019.4.21f, targeting platform android on Windows 10 OS.

@google-oss-bot google-oss-bot added needs-attention Need Googler's attention and removed needs-info Need information for the developer labels May 7, 2021
@DellaBitta DellaBitta added type: bug needs-info Need information for the developer and removed needs-attention Need Googler's attention type: question type: bug labels May 7, 2021
@DellaBitta
Copy link
Contributor

Hi @dacodelaac,

I attempted to reproduce this with the Storage Test App using Upload Stream with airplane mode enabled on and Android device. I'm getting an retry limit exceeded exception as expected. I tested with Firebase Unity SDK 7.2.0.

Steps taken:

  • Launch App
  • Enable Airplane mode on the device.
  • Scroll down through the test app and set Max Operation Retry Time and Max Upload Retry Time to 1000, or 1 (I tried both).
  • Click on Upload Stream.

Note that the storage location configuration in the test app isn't important since we're squelching the network request.

Could you update these steps to cause a reproduction of the issue? Thanks.

@dacodelaac
Copy link
Author

Hi @DellaBitta,

I tested with Unity Editor 2019.4.21f, on Windows 10, target platform Android, Firebase Unity SDK 7.2.0

Step:

  • Launch app
  • Sign in successful
  • Try Upload Stream a few times to check if it works.
  • Disable internet adapter
  • Try Upload Stream again, get an exception ApplicationException: GetFutureStatus(handle) == kFutureStatusPending, and the upload task will never be completed even if you enable the internet adapter. That why I cannot get retry limit exceeded exception because the task looks like it running forever.

@google-oss-bot google-oss-bot added needs-attention Need Googler's attention and removed needs-info Need information for the developer labels May 10, 2021
@patm1987
Copy link

Hi @dacodelaac ,

Can you verify whether you're seeing the issue when running in the Unity editor (pressing the play button) or on a physical Android device?

Thanks
--Patrick

@dacodelaac
Copy link
Author

@patm1987 ,

I can still reproduce this issue on Unity Editor

  • Disable internet adapter
  • Press play button
  • Press Upload Stream
  • See exception (I think it is normal because we don't have internet connection)
System.AggregateException: One or more errors occurred. ---> Firebase.Storage.StorageException: The server did not return a valid JSON response.  Contact Firebase support if this issue persists.
   --- End of inner exception stack trace ---
---> (Inner Exception #0) Firebase.Storage.StorageException: The server did not return a valid JSON response.  Contact Firebase support if this issue persists.<---

UnityEngine.Debug:Log (object)
Firebase.Sample.Storage.UIHandler:DebugLog (string) (at Assets/Firebase/Sample/Storage/UIHandler.cs:114)
Firebase.Sample.Storage.UIHandler:DisplayStorageException (System.Exception) (at Assets/Firebase/Sample/Storage/UIHandler.cs:211)
Firebase.Sample.Storage.UIHandler/WaitForTaskCompletion:get_keepWaiting () (at Assets/Firebase/Sample/Storage/UIHandler.cs:174)
UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr)
  • Press Upload Stream again
  • Exception:
ApplicationException: GetFutureStatus(handle) == kFutureStatusPending
Rethrow as ApplicationException: backing->status != kFutureStatusComplete
Firebase.Storage.StorageReferenceInternal.PutBytesUsingMonitorControllerAsync (System.IntPtr buffer, System.UInt32 buffer_size, Firebase.Storage.MetadataInternal metadata, Firebase.Storage.MonitorControllerInternal monitor_controller) (at Z:/tmp/tmp.0Ryilsblb3/firebase/storage/client/unity/proxy/StorageReferenceInternal.cs:148)
Firebase.Storage.StorageReference.PutBytesUsingMonitorControllerAsync (System.IntPtr buffer, System.UInt32 bufferSize, Firebase.Storage.MetadataInternal metadata, Firebase.Storage.MonitorControllerInternal monitorController, System.Threading.CancellationToken cancellationToken) (at Z:/tmp/tmp.0Ryilsblb3/firebase/storage/client/unity/proxy/StorageReference.cs:276)
Firebase.Storage.StorageReference.PutBytesUsingCompletionSourceAsync (System.Byte[] bytes, Firebase.Storage.MetadataChange customMetadata, System.IProgress`1[T] progressHandler, System.Threading.CancellationToken cancelToken, System.Uri previousSessionUri, System.Threading.Tasks.TaskCompletionSource`1[TResult] completionSource) (at Z:/tmp/tmp.0Ryilsblb3/firebase/storage/client/unity/proxy/StorageReference.cs:309)
Firebase.Storage.StorageReference <PutStreamAsync>c__AnonStorey7.<>m__0 () (at Z:/tmp/tmp.0Ryilsblb3/firebase/storage/client/unity/proxy/StorageReference.cs:457)
System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.Threading.ThreadHelper.ThreadStart () (at <eae584ce26bc40229c1b1aa476bfa589>:0)
UnityEngine.<>c:<RegisterUECatcher>b__0_0(Object, UnhandledExceptionEventArgs)
  • Then, you cannot press Upload Stream anymore because the previous task is not completed.

PS: Just tested it on my phone, this issue did not exist.

@patm1987
Copy link

I can confirm that I see this with the storage quickstart. MacOS host. Android target. Running in the Unity Editor. Unity 2021.1.3f1. Storage SDK 7.2.0.

The first time I upload I get a normal exception that's handled appropriately.
The second time it hangs with kFutureStatusPending and fails to continue even after re-establishing networking connectivity.

I'm going to mark this as a bug but as something that only shows up in the Editor. If you see it on device (Android/iOS phone/tablet) as well, let us know as it may effect prioritization!

@patm1987 patm1987 added type: bug and removed needs-attention Need Googler's attention type: question labels May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants