rebuy-de / rb-forms-barcode

Rb.Forms.Barcode is a Xamarin.Forms view for scanning barcodes.
https://github.com/rebuy-de/rb-forms-barcode
MIT License
43 stars 21 forks source link

Scanner randomly crashes under Android -- "index out of range" -- NavigationStack becomes corrupt #59

Closed marcusts closed 7 years ago

marcusts commented 7 years ago

I am using the bar code scanner in both IOS (which works) and Android (which is broken). I don't have any proprietary code. I just call the Init. The test is to open and close the scanner using PushModalAsync and then to close it using PopModalAsync. After 3-4 tries, the app crashes with the stack trace at the bottom of this issue.

I can stop the error by checking the NavigationStack to see if it has any members. hen it is about to crash, the stack has zero members. But if I do that, the user will never be able to close the modal scanner.

I cannot test your code or the test app there because I cannot get your code from the GitHub site to compile. See my other issue for details about that.

STACK TRACE

12-15 11:41:43.389 I/MonoDroid(30476): UNHANDLED EXCEPTION: 12-15 11:41:43.399 I/MonoDroid(30476): System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. 12-15 11:41:43.399 I/MonoDroid(30476): Parameter name: index 12-15 11:41:43.399 I/MonoDroid(30476): at System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) [0x00000] in /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/referencesource/mscorlib/system/throwhelper.cs:93 12-15 11:41:43.399 I/MonoDroid(30476): at System.ThrowHelper.ThrowArgumentOutOfRangeException () [0x00000] in /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/referencesource/mscorlib/system/throwhelper.cs:56 12-15 11:41:43.399 I/MonoDroid(30476): at System.Collections.Generic.List1[T].get_Item (System.Int32 index) [0x0000c] in /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/referencesource/mscorlib/system/collections/generic/list.cs:181 12-15 11:41:43.399 I/MonoDroid(30476): at Xamarin.Forms.Application+NavigationImpl+<OnPopModal>d__2.MoveNext () [0x0000d] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\Application.cs:302 12-15 11:41:43.399 I/MonoDroid(30476): --- End of stack trace from previous location where exception was thrown --- 12-15 11:41:43.399 I/MonoDroid(30476): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 12-15 11:41:43.399 I/MonoDroid(30476): at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 12-15 11:41:43.409 I/MonoDroid(30476): at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 12-15 11:41:43.409 I/MonoDroid(30476): at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 12-15 11:41:43.409 I/MonoDroid(30476): at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357 12-15 11:41:43.409 I/MonoDroid(30476): at TPI_Mobile_Common.Controls.ScannerPage+<<-ctor>b1_0>d.MoveNext () [0x00025] in C:\Source\TPIMobile\Xamarin\TPI_Telogis_V1\Controls\ScannerPage.xaml.cs:36 12-15 11:41:43.409 I/MonoDroid(30476): --- End of stack trace from previous location where exception was thrown --- 12-15 11:41:43.409 I/MonoDroid(30476): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 12-15 11:41:43.409 I/MonoDroid(30476): at System.Runtime.CompilerServices.AsyncMethodBuilderCore.m0 (System.Object state) [0x00000] in /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1018 12-15 11:41:43.409 I/MonoDroid(30476): at Android.App.SyncContext+cAnonStorey0.<>m__0 () [0x00000] in /Users/builder/data/lanes/3511/ce955cc0/source/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:18 12-15 11:41:43.409 I/MonoDroid(30476): at Java.Lang.Thread+RunnableImplementor.Run () [0x0000b] in /Users/builder/data/lanes/3511/ce955cc0/source/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36 12-15 11:41:43.409 I/MonoDroid(30476): at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr nativethis) [0x00009] in /Users/builder/data/lanes/3511/ce955cc0/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Java.Lang.IRunnable.cs:81 12-15 11:41:43.409 I/MonoDroid(30476): at (wrapper dynamic-method) System.Object:6f241252-866a-4903-a936-1c7f81336bfc (intptr,intptr) 12-15 11:41:43.419 D/Mono (30476): Assembly Ref addref HockeySDK.AndroidBindings[0xb3feece0] -> System[0xaa467560]: 16 12-15 11:41:43.439 W/art (30476): JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable

marcusts commented 7 years ago

I discovered that this was due to failing to call Init early on, per the examples. I was doing this elsewhere for my own reasons, so felt it was redundant. It is not an optional call. Do Init at AppDelegate and at MainActivity, and this error will not occur.

rdoubleui commented 7 years ago

So this can be closed?

marcusts commented 7 years ago

Just that issue, yes. The other issue -- where you failed t provide two files needed for compilation - must remain open until you remedy the problem.

Stephen

On Fri, Dec 16, 2016 at 2:56 AM, Rajko Winkler notifications@github.com wrote:

So this can be closed?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rebuy-de/rb-forms-barcode/issues/59#issuecomment-267569450, or mute the thread https://github.com/notifications/unsubscribe-auth/AG3ZC0bkBKF2ZwLmqb8c_pugL7bvhHbCks5rIm5wgaJpZM4LOfzF .