I am building a simple C# mono application that queries data from parse.com server.
Nothing special:
private static async Task<ParseGameData> DownloadGameData(DateTime dateFrom)
{
ParseGameData gameData = new ParseGameData();
InitParse();
var qHits = ParseObject.GetQuery("Hits").WhereGreaterThan("createdAt", dateFrom)
.Limit(100).OrderBy("createdAt");
gameData.hits = await qHits.FindAsync();
return gameData;
}
And called from another function:
ParseGameData gameData = DownloadGameData(timestamp).Result;
This works great and no exception is being thrown when querying small amount (~less than 75 records). But if I set the limit higher, application crashes and I get this:
Unhandled Exception:
System.StackOverflowException: The requested operation caused a stack overflow.
at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <filename unknown>:0
at System.Threading.Tasks.Task.FinishStageThree () [0x00000] in <filename unknown>:0
at System.Threading.Tasks.Task`1[System.Threading.Tasks.TaskExtensions+VoidResult].TrySetResult (VoidResult result) [0x00000] in <filename unknown>:0
at System.Threading.Tasks.UnwrapPromise`1[System.Threading.Tasks.TaskExtensions+VoidResult].TrySetFromTask (System.Threading.Tasks.Task task, Boolean lookForOce) [0x00000] in <filename unknown>:0
at System.Threading.Tasks.UnwrapPromise`1[System.Threading.Tasks.TaskExtensions+VoidResult].InvokeCore (System.Threading.Tasks.Task completingTask) [0x00000] in <filename unknown>:0
at System.Threading.Tasks.UnwrapPromise`1[System.Threading.Tasks.TaskExtensions+VoidResult].Invoke (System.Threading.Tasks.Task completingTask) [0x00000] in <filename unknown>:0
... and then these lines repeat.
For interest purposes: each record in database takes about ~65KB, so a 100 hits would be 6.5MB.
I've tried this code on two mono platforms, on OS X and Linux. Both platforms throw stackoverflow exceptions. However on Windows, using .NET, it works fine, even with 1000 limit. That leads me to believe it is something with mono and parse.com libraries. Any suggestions?
It seems like it was a parse library bug. I have downgraded parse lib from 1.5.5 to 1.5.4 and now it works fine.
Related
I am having a weird issue with the entry point of my app in App.xaml.cs when an interface is being resolved by Prism MVVM.
public App(IPlatformIniializer initializer) : base(initializer) {}
Stack Trace
The issue I am having does not stem from my code (at least I can't see so) so here is the stack trace as I do not know what to post, and I can't post my entire project here.
The error starts in CreateFormsApp() as the trace shows, the line is var app = new App(new AndroidInitializer());
And then from there, it goes into Prisms library code. I had a look at their source code and I can see it on like 150 of this.
When IModuleCatalog is being resolved it throws an error, I don't know how I can fix something like this.
Has anyone encountered this before?
at Prism.DryIoc.DryIocContainerExtension.Resolve (System.Type type, System.ValueTuple`2[System.Type,System.Object][] parameters) [0x00053] in /_/src/Containers/Prism.DryIoc.Shared/DryIocContainerExtension.cs:298
at Prism.DryIoc.DryIocContainerExtension.Resolve (System.Type type) [0x00000] in /_/src/Containers/Prism.DryIoc.Shared/DryIocContainerExtension.cs:272
at Prism.Ioc.IContainerProviderExtensions.Resolve[T] (Prism.Ioc.IContainerProvider provider) [0x00000] in /_/src/Prism.Core/Ioc/IContainerProviderExtensions.cs:18
at Prism.PrismApplicationBase.Initialize () [0x00057] in /_/src/Forms/Prism.Forms/PrismApplicationBase.cs:150
at Prism.PrismApplicationBase.InitializeInternal () [0x00006] in /_/src/Forms/Prism.Forms/PrismApplicationBase.cs:94
at Prism.PrismApplicationBase..ctor (Prism.IPlatformInitializer platformInitializer) [0x00031] in /_/src/Forms/Prism.Forms/PrismApplicationBase.cs:72
at Prism.DryIoc.PrismApplication..ctor (Prism.IPlatformInitializer platformInitializer) [0x00000] in /_/src/Forms/Prism.DryIoc.Forms/PrismApplication.cs:25
at MyApp.App..ctor (Prism.IPlatformInitializer initializer) [0x00000] in C:\Users\Steve\source\repos\MyApp\MyApp\App.xaml.cs:50
at MyApp.Droid.MainActivity.CreateFormsApp (Android.OS.Bundle bundle) [0x0021e] in C:\Users\Steve\source\repos\MyApp\MyApp.Android\MainActivity.cs:226
I have a lot of uitests for Xamarin.Forms app. These tests under categories. (For example LoginTest category has 10 tests, InboxTest category has 40 tests etc.) When I select 1 category (or when I select more than categories) and run it on iOS simulator, firstly tests of these categories runs, but after a while some tests don't run.
And I encounter this error:
Connection closed
Stack trace:
at MonoDevelop.Core.Execution.RemoteProcessConnection.SendMessage[RT] (MonoDevelop.Core.Execution.BinaryMessage`1[RT] message) [0x00024] in /Users/builder/azdo/_work/1/s/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/RemoteProcessConnection.cs:374
at MonoDevelop.UnitTesting.NUnit.External.ExternalTestRunner.Run (MonoDevelop.UnitTesting.NUnit.External.IRemoteEventListener listener, System.String[] nameFilter, System.String path, System.String suiteName, System.Collections.Generic.List`1[T] supportAssemblies, System.String testRunnerType, System.String testRunnerAssembly, System.String crashLogFile) [0x00099] in /Users/builder/azdo/_work/1/s/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit/ExternalTestRunner.cs:91
at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread () [0x001b6] in C:\A_work\107\s\src\Microsoft.VisualStudio.Threading\JoinableTask.cs:916
at Microsoft.VisualStudio.Threading.JoinableTask`1[T].CompleteOnCurrentThread () [0x00000] in C:\A_work\107\s\src\Microsoft.VisualStudio.Threading\JoinableTask`1.cs:84
at Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[T] (System.Func`1[TResult] asyncMethod, Microsoft.VisualStudio.Threading.JoinableTaskCreationOptions creationOptions) [0x0000e] in C:\A_work\107\s\src\Microsoft.VisualStudio.Threading\JoinableTaskFactory.cs:505
at Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[T] (System.Func`1[TResult] asyncMethod) [0x00000] in C:\A_work\107\s\src\Microsoft.VisualStudio.Threading\JoinableTaskFactory.cs:484
at MonoDevelop.UnitTesting.NUnit.NUnitAssemblyTestSuite.RunUnitTest (MonoDevelop.UnitTesting.UnitTest test, System.String suiteName, System.String pathName, System.String testName, MonoDevelop.UnitTesting.TestContext testContext) [0x00265] in /Users/builder/azdo/_work/1/s/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit/NUnitAssemblyTestSuite.cs:535
at MonoDevelop.UnitTesting.NUnit.NUnitTestSuite.OnRun (MonoDevelop.UnitTesting.TestContext testContext) [0x00000] in /Users/builder/azdo/_work/1/s/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit/NUnitTestSuite.cs:79
at MonoDevelop.UnitTesting.UnitTest.Run (MonoDevelop.UnitTesting.TestContext testContext) [0x0001c] in /Users/builder/azdo/_work/1/s/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTest.cs:351
When I run it one by one, they run.
My Visual Studio mac version is 8.8.4 (up to date)
Xamarin.TestCloud.Agent version is 0.22.1
Xamarin.UITest version is 3.0.12
What must I do?
Thank you in advance.
I'm seeing this cryptic exception that's been documented on bugzilla.xamarin.com periodically. Most of the posts suggest you can suppress the error by changing the bridge implementation to the Old version instead of Tarjan by setting an environment variable:
MONO_GC_PARAMS=bridge-implementation=old
I set the variable, but I don't see anything in my logcat or build output to indicate it's using one bridge or the other, and I'm still getting the exception. Is there a way to tell which implementation is being used?
Here's the stack trace - any suggestions are greatly appreciated.
Process: com.icon.iconsurvey, PID: 11543
android.runtime.JavaProxyThrowable: System.ArgumentException: Handle must be valid.
Parameter name: instance
at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00009] in <7cfbebb561c54efc9010b018c0846c7e>:0
at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (System.IntPtr jobject, System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue* parms) [0x00015] in <e975227ac8644a30bb0866117325de0d>:0
at Android.Support.V4.Widget.DrawerLayout.RemoveDrawerListener (Android.Support.V4.Widget.DrawerLayout+IDrawerListener listener) [0x00088] in <fc4222de5c684a9abf7cc4821baac4cd>:0
at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.Dispose (System.Boolean disposing) [0x000e4] in <b5b1173f4d49442b898c45e26ae39e48>:0
at Java.Lang.Object.Dispose () [0x00000] in <e975227ac8644a30bb0866117325de0d>:0
at Xamarin.Forms.Platform.Android.AppCompat.Platform+<>c__DisplayClass35_0.<SetPage>b__0 () [0x00015] in <b5b1173f4d49442b898c45e26ae39e48>:0
at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <e975227ac8644a30bb0866117325de0d>:0
at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <e975227ac8644a30bb0866117325de0d>:0
at (wrapper dynamic-method) System.Object:1d7dae73-d3c1-4d29-aa82-708ecaa93ad1 (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:145)
at android.app.ActivityThread.main(ActivityThread.java:6939)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
The current suggestion is using new rather than old when changing the default GC Bridge away from tarjan. You may have been told to use the "old" default which was technically new before changing to tarjan in Mono 4.6:
http://www.mono-project.com/docs/about-mono/releases/4.6.0/#new-default-gc-bridge-processor-on-android
You can see if this is being picked up by checking the Diagnostic Build Output of your project.
https://developer.xamarin.com/guides/android/troubleshooting/troubleshooting/#Diagnostic_MSBuild_Output
You would then look to ensure the configuration file is picked up with the respective arguments.
I get the following error while executing my Xamarin Android app in release mode. I suppose something is missing in LinkerPleaseInclude.cs, but the error message is not very helpful.
09-25 16:17:38.140 W/art ( 1082): JNI RegisterNativeMethods: attempt to register 0 native methods for mvvmcross.binding.droid.views.MvxRadioGroup
[0:] MvxBind:Error: 2,89 Exception thrown during the view binding ArgumentNullException: missing source event info in MvxWeakEventSubscription
Parameter name: sourceEventInfo
at MvvmCross.Platform.WeakSubscription.MvxWeakEventSubscription`2[TSource,TEventArgs]..ctor (Android.Widget.TextView source, System.Reflection.EventInfo sourceEventInfo, System.EventHandler`1[TEventArgs] targetEventHandler) [0x00017] in <54d9eb77c4d448d4bc5e7c7a5cdd0a97>:0
at MvvmCross.Platform.WeakSubscription.MvxWeakEventSubscription`2[TSource,TEventArgs]..ctor (Android.Widget.TextView source, System.String sourceEventName, System.EventHandler`1[TEventArgs] targetEventHandler) [0x00012] in <54d9eb77c4d448d4bc5e7c7a5cdd0a97>:0
at MvvmCross.Platform.WeakSubscription.MvxWeakSubscriptionExtensionMethods.WeakSubscribe[TSource,TEventArgs] (TSource source, System.String eventName, System.EventHandler`1[TEventArgs] eventHandler) [0x00000] in <54d9eb77c4d448d4bc5e7c7a5cdd0a97>:0
at MvvmCross.Binding.Droid.Target.MvxTextViewTextTargetBinding.SubscribeToEvents () [0x0000b] in <cc9453c0f5794d529a8b1975bb62dd40>:0
at MvvmCross.Binding.Bindings.MvxFullBinding.CreateTargetBinding (System.Object target) [0x00057] in <5d9349f2d9c240e38eaeca40fe71d977>:0
at MvvmCross.Binding.Bindings.MvxFullBinding..ctor (MvvmCross.Binding.MvxBindingRequest bindingRequest) [0x0002f] in <5d9349f2d9c240e38eaeca40fe71d977>:0
at MvvmCross.Binding.Binders.MvxFromTextBinder.BindSingle (MvvmCross.Binding.MvxBindingRequest bindingRequest) [0x00000] in <5d9349f2d9c240e38eaeca40fe71d977>:0
at MvvmCross.Binding.Binders.MvxFromTextBinder+<>c__DisplayClass2_0.<Bind>b__0 (MvvmCross.Binding.Bindings.MvxBindingDescription description) [0x00018] in <5d9349f2d9c240e38eaeca40fe71d977>:0
at System.Linq.Utilities+<>c__DisplayClass2_0`3[TSource,TMiddle,TResult].<CombineSelectors>b__0 (TSource x) [0x00012] in <9ecdeee51aa740839577d6db9550e95f>:0
at System.Linq.Utilities+<>c__DisplayClass2_0`3[TSource,TMiddle,TResult].<CombineSelectors>b__0 (TSource x) [0x00000] in <9ecdeee51aa740839577d6db9550e95f>:0
at (wrapper delegate-invoke) System.Func`2[System.Collections.Generic.KeyValuePair`2[System.String,MvvmCross.Binding.Parse.Binding.MvxSerializableBindingDescription],System.Collections.Generic.KeyValuePair`2[System.Object,MvvmCross.Binding.Bindings.IMvxUpdateableBinding]]:invoke_TResult_T (System.Collections.Generic.KeyValuePair`2<string, MvvmCross.Binding.Parse.Binding.MvxSerializableBindingDescription>)
at System.Linq.Enumerable+SelectEnumerableIterator`2[TSource,TResult].MoveNext () [0x00048] in <9ecdeee51aa740839577d6db9550e95f>:0
at System.Collections.Generic.List`1[T].InsertRange (System.Int32 index, System.Collections.Generic.IEnumerable`1[T] collection) [0x000ea] in <b2855d13f99e445b95990a59348d98e8>:0
at System.Collections.Generic.List`1[T].AddRange (System.Collections.Generic.IEnumerable`1[T] collection) [0x00000] in <b2855d13f99e445b95990a59348d98e8>:0
at MvvmCross.Binding.Droid.Binders.MvxAndroidViewBinder.StoreBindings (Android.Views.View view, System.Collections.Generic.IEnumerable`1[T] newBindings) [0x00028] in <cc9453c0f5794d529a8b1975bb62dd40>:0
at MvvmCross.Binding.Droid.Binders.MvxAndroidViewBinder.ApplyBindingsFromAttribute (Android.Views.View view, Android.Content.Res.TypedArray typedArray, System.Int32 attributeId) [0x0001c] in <cc9453c0f5794d529a8b1975bb62dd40>:0
I see, something is missing with MvxRadioGroup. How do I find out what to add in LinkerPleaseInclude?
My binding for MvxRadioGroup is the following:
<MvxRadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="6dp"
local:MvxBind="ItemsSource GenderAnswers; SelectedItem GenderAnswer"
local:MvxItemTemplate="#layout/radioitem_enum" />
and my LinkerPleaseInclude is still empty.
Here's the defintiion of the properties in view model:
public IEnumerable<GenderQuestionAnswers> GenderAnswers => Enum.GetValues(typeof(GenderQuestionAnswers)).Cast<GenderQuestionAnswers>();
public GenderQuestionAnswers? GenderAnswer
{
get => _genderAnswer;
set => SetProperty(ref _genderAnswer, value);
}
[edit 2017-09-27]: added code for MvxRadioGroup binding
[edit 2017-09-27]: added snippet for properties in view model
I ended up adding theses lines to LinkerPleaseInclude in addition to the file mentioned by #york-shen-msft
public void Include(RadioButton radioButton)
{
radioButton.CheckedChange += (sender, args) => radioButton.Checked = args.IsChecked
}
Well, that doesn't really answer my question as I wanted to know how to find the correct solution without searching the whole internet for lines others included before and do trial and error, but it solves my actual problem for the moment.
I'm using Realm in my Xamarin app, and I'm getting this exception in production. I have never seen it running the app myself, and it occurs only a few times daily. The complete stack trace is:
System.AggregateException', reason: 'System.AggregateException:
A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread.
---> Realms.RealmInvalidTransactionException: The Realm is already in a write transaction at Realms.NativeException.ThrowIfNecessary (System.Func`2 overrider) <0xab3dfc + 0x00038> in <filename unknown>:0
at Realms.SharedRealmHandle.BeginTransaction () <0xab21c8 + 0x00043> in <filename unknown>:0
at Realms.Transaction..ctor (Realms.SharedRealmHandle sharedRealmHandle) <0xab9ad8 + 0x0002f> in <filename unknown>:0
at Realms.Realm.BeginWrite () <0xab7624 + 0x0003f> in <filename unknown>:0
at Realms.Realm.Write (System.Action action) <0xab7674 + 0x0002b> in <filename unknown>:0
at MyApp.iOS.CollectionViewSource+<GetCell>c__AnonStorey0.<>m__2 (System.Threading.Tasks.Task`1 value) <0x327c34 + 0x001b3> in <filename unknown>:0
at System.Threading.Tasks.ContinuationTaskFromResultTask`1[TAntecedentResult].InnerInvoke () <0x532fa8 + 0x00077> in <filename unknown>:0
at System.Threading.Tasks.Task.Execute () <0x52ed88 + 0x0005b> in <filename unknown>:0
I'm sure that my app only have one write transaction opened at once. The only thing that I think may be causing problems is that the realm transaction don't close properly. My code is something like this:
// this is called at some point in the app, when entering in a specific view controller
var transaction = realm.BeginWrite ();
The code for close this Controller is:
public void Close(bool saveChanges) {
if (saveChanges) {
transaction.Commit ();
transaction.Dispose ();
}
else {
transaction.Rollback ();
transaction.Dispose ();
}
// Ignore the fact that this code can be included in the previous section
// It is just for making clear that after closing the transaction I can make
// a simple change to the objects
if (saveChanges) {
realm.Write(() => {
model.id = 1;
}
}
NavigationController.PopToRootViewController (true);
}
When the root view controller is shown, then it accesses to the realm data and in this moment is when the crash occurred.
Any hint regarding to what can be happening here?
My first reaction was that the most likely thing is that your Close is not always being called. Is there any way your app can make a transition to another screen, or re-enter this one, without calling Close?
However
Looking at your stack trace, something that struck me is that you are apparently calling a Write from a cell getter, which is what is causing the crash:
MyApp.iOS.CollectionViewSource+<GetCell...
Do you have a list that is being refreshed whilst that screen is open?
Update
One thing to note from the comments below, that may be confusing you.
There are two ways to start a write transaction in Realm.
BeginTransaction creates and returns a transaction, so you have the chance to call Rollback.
The Realm.Write( lambda ) call also creates a temporary Write Transaction so you cannot invoke it on the same thread.
I think this is a possible source of confusion and will discuss with the team if we should both update the docs and also try to improve the exception messages to pick up if a Write is being called in this situation.