Bug 51757 - Enumerable.Last[TSource] android.runtime.JavaProxyThrowable: System.InvalidOperationException: Sequence contains no elements
Summary: Enumerable.Last[TSource] android.runtime.JavaProxyThrowable: System.InvalidOp...
Status: RESOLVED NORESPONSE
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.3.3
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Paul DiPietro [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2017-01-25 09:38 UTC by Jan Nepras
Modified: 2018-05-03 14:54 UTC (History)
4 users (show)

Tags: android
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NORESPONSE

Description Jan Nepras 2017-01-25 09:38:03 UTC
I found this bug in HockeyApp. It looks like the Navigation Stack is empty before PopToRoot method is called.

DEVICE:

SM-N910W8

INFO:

Enumerable.Last[TSource]

android.runtime.JavaProxyThrowable: System.InvalidOperationException: Sequence contains no elements

Xamarin caused by: android.runtime.JavaProxyThrowable: System.InvalidOperationException: Sequence contains no elements
System.Linq.Enumerable.Last<TSource>(IEnumerable<T> source)<33ef3afef94648f9a785a708ba27c4cd>:0
Xamarin.Forms.NavigationProxy.OnPopToRootAsync(bool animated)<bf304fc411724e23a42595b76799a13a>:0
Xamarin.Forms.NavigationProxy.PopToRootAsync()<bf304fc411724e23a42595b76799a13a>:0
SafetyLineMobileApps.View.TextMessagePage.<<OnEntryTextChanged>b__5_3>d.MoveNext()<1e18ae9702b44a52bb6bc687ded82a55>:0
Android.App.SyncContext.<Post>c__AnonStorey0.<>m__0()<45785641d5504f1a87825c6601db823b>:0
Java.Lang.Thread.RunnableImplementor.Run()<45785641d5504f1a87825c6601db823b>:0
Java.Lang.IRunnableInvoker.n_Run(IntPtr jnienv, IntPtr native__this)<45785641d5504f1a87825c6601db823b>:0
at (wrapper dynamic-method) System.Object:6f7e73c2-b7bd-4dc3-b612-5400375c4bd2 (intptr,intptr)
mono.java.lang.RunnableImplementor.n_run(Native Method)
mono.java.lang.RunnableImplementor.run()RunnableImplementor.java:30
android.os.Handler.handleCallback()Handler.java:739
android.os.Handler.dispatchMessage()Handler.java:95
android.os.Looper.loop()Looper.java:158
android.app.ActivityThread.main()ActivityThread.java:7225
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run()ZygoteInit.java:1230
com.android.internal.os.ZygoteInit.main()ZygoteInit.java:1120
Comment 1 Hines Vaughan III 2017-02-12 19:56:21 UTC
Seeing this issue as well, also reported through HockeyApp except the StackTrace and source of the exception is through PushModalAsync(). Also I am not using Enumerable.Last anywhere in my code so I think it might be happening in the Xamarin code somewhere but have not been able to recreate it.

Devices:
- SAMSUNG SAMSUNG-SM-G890A - 6.0.1
- SAMSUNG SCH-I545 - 5.0.1

Xamarin Forms Version being used:
- 2.3.3.175

StackTrace:

Xamarin caused by: android.runtime.JavaProxyThrowable: System.InvalidOperationException: Sequence contains no elements
  at System.Linq.Enumerable.Last[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x0007e] in <086d570469514a66be9aeb3462ce0b58>:0 
  at Xamarin.Forms.Platform.Android.Platform+<Xamarin-Forms-INavigation-PushModalAsync>d__53.MoveNext () [0x000fc] in <556464d784854d58957ce21f4c5eb182>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <212969afb64442ecbcd31fd8adda3fe7>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <212969afb64442ecbcd31fd8adda3fe7>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <212969afb64442ecbcd31fd8adda3fe7>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <212969afb64442ecbcd31fd8adda3fe7>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <212969afb64442ecbcd31fd8adda3fe7>:0 
  at Xamarin.Forms.Application+NavigationImpl+<OnPushModal>d__3.MoveNext () [0x000d5] in <bf304fc411724e23a42595b76799a13a>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <212969afb64442ecbcd31fd8adda3fe7>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <212969afb64442ecbcd31fd8adda3fe7>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <212969afb64442ecbcd31fd8adda3fe7>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <212969afb64442ecbcd31fd8adda3fe7>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <212969afb64442ecbcd31fd8adda3fe7>:0 
  at TheCrawfishApp.WelcomeCrawfishTypePage+<Initialize>c__asyncB.MoveNext () [0x000c3] in <ed15230a377c4be6a5c4952db3ee3e25>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <212969afb64442ecbcd31fd8adda3fe7>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>m__0 (System.Object state) [0x00000] in <212969afb64442ecbcd31fd8adda3fe7>:0 
  at Android.App.SyncContext+<Post>c__AnonStorey0.<>m__0 () [0x00000] in <a9e2f49123bb4734b0685313855b5680>:0 
  at Java.Lang.Thread+RunnableImplementor.Run () [0x0000b] in <a9e2f49123bb4734b0685313855b5680>:0 
  at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <a9e2f49123bb4734b0685313855b5680>:0 
  at (wrapper dynamic-method) System.Object:85eb1085-5acc-4fa0-9d76-5766b943d43b (intptr,intptr)
	at mono.java.lang.RunnableImplementor.n_run(Native Method)
	at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
	at android.os.Handler.handleCallback(Handler.java:739)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:158)
	at android.app.ActivityThread.main(ActivityThread.java:7237)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Comment 2 Paul DiPietro [MSFT] 2017-03-27 18:11:46 UTC
Hi, do you have a reproduction project you can provide to help investigate this? Have you also tested against the latest prerelease/nightly, by chance?
Comment 3 Paul DiPietro [MSFT] 2017-06-15 16:40:27 UTC
Closing this due to no response so we will reasonably assume this is no longer an issue. Please reopen and attach a minimized reproduction project if the issue still exists as of the latest prerelease or nightly build.
Comment 4 norman.schuett 2018-05-03 14:54:17 UTC
I have this issue aswell in Xamarin.Forms 2.5.1.444931.

Theres no difference between PopToRootAsync and PopAsync.
Unfortunately I cannot reproduce this in a new Project therefor I have no reproduction Project at the moment.

The "Navigation.Inner" Property is null when it happens.
(NavigationProxy.NavigationImpl)