我正在与一个团队一起使用 MvvmCross 创建一个 android 应用程序。最近我们开始看到大量重复的警告/错误消息,看起来像这样:
MvxBind:Warning:207.06 Weak Target is null in MvxWithEventPropertyInfoTargetBinding - skipping set
[0:] MvxBind:Warning:207.06 Weak Target is null in MvxWithEventPropertyInfoTargetBinding - skipping set
09-05 17:56:25.076 I/MvxBind (20932): 207.06 Weak Target is null in MvxWithEventPropertyInfoTargetBinding - skipping set
09-05 17:56:25.086 I/mono-stdout(20932): MvxBind:Warning:207.06 Weak Target is null in MvxWithEventPropertyInfoTargetBinding - skipping set
[0:]
MvxBind:Warning:207.08 Weak Target is null in MvxTextViewTextTargetBinding - skipping set
[0:] MvxBind:Warning:207.08 Weak Target is null in MvxTextViewTextTargetBinding - skipping set
09-05 17:56:25.096 I/MvxBind (20932): 207.08 Weak Target is null in MvxTextViewTextTargetBinding - skipping set
09-05 17:56:25.096 I/mono-stdout(20932): MvxBind:Warning:207.08 Weak Target is null in MvxTextViewTextTargetBinding - skipping set
[0:]
09-05 17:56:25.116 I/MvxBind (20932): 207.10 Weak Target is null in MvxTextViewTextTargetBinding - skipping set
MvxBind:Warning:207.10 Weak Target is null in MvxTextViewTextTargetBinding - skipping set
[0:] MvxBind:Warning:207.10 Weak Target is null in MvxTextViewTextTargetBinding - skipping set
09-05 17:56:25.126 I/mono-stdout(20932): MvxBind:Warning:207.10 Weak Target is null in MvxTextViewTextTargetBinding - skipping set
[0:]
09-05 17:56:25.126 I/MvxBind (20932): 207.12 Weak Target is null in MvxWithEventPropertyInfoTargetBinding - skipping set
MvxBind:Warning:207.12 Weak Target is null in MvxWithEventPropertyInfoTargetBinding - skipping set
[0:] MvxBind:Warning:207.12 Weak Target is null in MvxWithEventPropertyInfoTargetBinding - skipping set
09-05 17:56:25.136 I/mono-stdout(20932): MvxBind:Warning:207.12 Weak Target is null in MvxWithEventPropertyInfoTargetBinding - skipping set
这些消息在从显示 MvxGridView 的视图切换后大约 3 分钟开始。MvxGridview 绑定到一组视图模型,每个模型都有自己的绑定。消息一直持续到应用程序停止。消息一开始,用户界面就会变得越来越迟钝,并最终完全锁定。有趣的是,从该屏幕切换似乎是触发因素。我可以切换屏幕然后什么也不做,大约 3 分钟,大量消息将开始涌入。如果我将应用程序留在那个屏幕上,一切都会顺利进行。
最终,我只想知道如何解决问题,以便应用程序正常运行。可能有助于实现该目标的一些问题包括:
- 是否可以从 MvvmCross 获得更详细的堆栈跟踪?已回答
- 我是否需要像这样手动处理 MvxGridView 的每个单元格中的绑定:Clear bindings in MvvmCross?(绑定会自动绑定,因此这可能会偏离轨道。)
编辑
这是Environment.StackTrace
来自 的变量DebugTrace.cs
。MvxTextViewTextTargetBinding
和的堆栈跟踪MvxWithEventPropertyInfoTargetBinding
完全相同。(为了便于阅读,我删除了处理调用 IMvxTrace.Trace 的堆栈跟踪的前几行。)
at Cirrious.MvvmCross.Binding.Bindings.Target.MvxPropertyInfoTargetBinding.SetValue(System.Object value)
at Cirrious.MvvmCross.Binding.Bindings.MvxFullBinding.UpdateTargetFromSource(Boolean isAvailable, System.Object value)
at Cirrious.MvvmCross.Binding.Bindings.MvxFullBinding.<CreateSourceBinding>b__0(System.Object sender, Cirrious.MvvmCross.Binding.Bindings.Source.MvxSourcePropertyBindingEventArgs args)
at Cirrious.MvvmCross.Binding.Bindings.SourceSteps.MvxSourceStep.SendSourcePropertyChanged(Boolean isAvailable, System.Object value)
at Cirrious.MvvmCross.Binding.Bindings.SourceSteps.MvxPathSourceStep.SourceBindingOnChanged(System.Object sender, Cirrious.MvvmCross.Binding.Bindings.Source.MvxSourcePropertyBindingEventArgs args)
at Cirrious.MvvmCross.Binding.Bindings.Source.MvxSourceBinding.FireChanged(Cirrious.MvvmCross.Binding.Bindings.Source.MvxSourcePropertyBindingEventArgs args)
at Cirrious.MvvmCross.Binding.Bindings.Source.Leaf.MvxLeafPropertyInfoSourceBinding.OnBoundPropertyChanged()
at Cirrious.MvvmCross.Binding.Bindings.Source.MvxPropertyInfoSourceBinding.SourcePropertyChanged(System.Object sender, System.ComponentModel.PropertyChangedEventArgs e)
at System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod , System.Object , System.Object[] , System.Exception ByRef )
at System.Reflection.MonoMethod.Invoke(System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)
at System.Reflection.MethodBase.Invoke(System.Object obj, System.Object[] parameters)
at Cirrious.CrossCore.WeakSubscription.MvxWeakEventSubscription`2[[System.ComponentModel.INotifyPropertyChanged, System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.ComponentModel.PropertyChangedEventArgs, System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].OnSourceEvent(System.Object sender, System.ComponentModel.PropertyChangedEventArgs e)
at Cirrious.MvvmCross.ViewModels.MvxNotifyPropertyChanged+<>c__DisplayClass1.<RaisePropertyChanged>b__0()
at Cirrious.CrossCore.Core.MvxMainThreadDispatcher.ExceptionMaskedAction(System.Action action)
at Cirrious.MvvmCross.Droid.Views.MvxAndroidMainThreadDispatcher+<>c__DisplayClass1.<RequestMainThreadAction>b__0(System.Object ignored)
at Android.App.SyncContext+<Post>c__AnonStorey2E.<>m__1F() in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.8.0-branch/b76e8ec4/source/monodroid/src/Mono.Android/src/Android.App/SyncContext.cs:line 23
at Java.Lang.Thread+RunnableImplementor.Run() in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.8.0-branch/b76e8ec4/source/monodroid/src/Mono.Android/src/Java.Lang/Thread.cs:line 32
at Java.Lang.IRunnableInvoker.n_Run(IntPtr jnienv, IntPtr native__this) in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.8.0-branch/b76e8ec4/source/monodroid/src/Mono.Android/platforms/android-15/src/generated/Java.Lang.IRunnable.cs:line 71
at System.Object.ea853478-e8d0-4bbe-8306-98c58e64097e(IntPtr , IntPtr )