消息MvvmCross洪水:"弱目标是在空... - 跳过集" [英] MvvmCross flood of messages: "Weak Target is null in ... - skipping set"

查看:156
本文介绍了消息MvvmCross洪水:"弱目标是在空... - 跳过集"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与一个团队合作创建使用MvvmCross一个Android应用程序。最近,我们已经开始看到重复,看起来像这样的警告/错误消息的洪水:

  MvxBind:警告:207.06弱目标为空在MvxWithEventPropertyInfoTargetBinding  - 跳过集
[0:] MvxBind:警告:207.06弱目标是MvxWithEventPropertyInfoTargetBinding空 - 跳过集
09-05 17:56:25.076 I / MvxBind(20932):207.06弱目标是MvxWithEventPropertyInfoTargetBinding空 - 跳过集
09-05 17:56:25.086 I /单标准输出(20932):MvxBind:警告:207.06弱目标为空在MvxWithEventPropertyInfoTargetBinding - 跳过集
[0:]
MvxBind:警告:207.08弱目标为空在MvxTextViewTextTargetBinding - 跳过集
[0:] MvxBind:警告:207.08弱目标是MvxTextViewTextTargetBinding空 - 跳过集
09-05 17:56:25.096 I / MvxBind(20932):207.08弱目标是MvxTextViewTextTargetBinding空 - 跳过集
09-05 17:56:25.096 I /单标准输出(20932):MvxBind:警告:207.08弱目标为空在MvxTextViewTextTargetBinding - 跳过集
[0:]
09-05 17:56:25.116 I / MvxBind(20932):207.10弱目标是MvxTextViewTextTargetBinding空 - 跳过集
MvxBind:警告:207.10弱目标为空在MvxTextViewTextTargetBinding - 跳过集
[0:] MvxBind:警告:207.10弱目标是MvxTextViewTextTargetBinding空 - 跳过集
09-05 17:56:25.126 I /单标准输出(20932):MvxBind:警告:207.10弱目标为空在MvxTextViewTextTargetBinding - 跳过集
[0:]
09-05 17:56:25.126 I / MvxBind(20932):207.12弱目标是MvxWithEventPropertyInfoTargetBinding空 - 跳过集
MvxBind:警告:207.12弱目标为空在MvxWithEventPropertyInfoTargetBinding - 跳过集
[0:] MvxBind:警告:207.12弱目标是MvxWithEventPropertyInfoTargetBinding空 - 跳过集
09-05 17:56:25.136 I /单标准输出(20932):MvxBind:警告:207.12弱目标为空在MvxWithEventPropertyInfoTargetBinding - 跳过集

这些消息从显示的MvxGridView视图切换远开始后约3分钟。该MvxGridview势必视图模型的集合,每个都有它自己的绑定。消息继续,直到应用程序停止。该UI一旦消息得到开始日益低迷,并最终完全锁定。有趣的是,从该屏幕切换远似乎是触发。我可以切换屏幕,然后什么都不做,约3分钟,和消息的洪水将开始泛滥。如果我离开了屏幕上的应用程序,一切顺利。

最后,我只是想知道如何让应用程序运行正常解决问题。有些问题可能​​有助于实现这一目标包括:


  1. 是否有可能获得MvvmCross更详细的堆栈跟踪? ANSWERED

  2. 请我需要在这样的MvxGridView的每个单元手动处置绑定:的在MvvmCross 清除绑定? (该绑定自动绑定,所以这可能是偏离了轨道。)


修改

这是从 DebugTrace.cs Environment.StackTrace 变量。为 MvxTextViewTextTargetBinding MvxWithEventPropertyInfoTargetBinding 堆栈跟踪都是一模一样的。 (为便于阅读,我删除了堆栈跟踪处理呼叫IMvxTrace.Trace的前几行。)

 在Cirrious.MvvmCross.Binding.Bindings.Target.MvxPropertyInfoTargetBinding.SetValue(System.Object的值)
   在Cirrious.MvvmCross.Binding.Bindings.MvxFullBinding.UpdateTargetFromSource(布尔isAvailable,System.Object的值)
   在Cirrious.MvvmCross.Binding.Bindings.MvxFullBinding< CreateSourceBinding> b__0(System.Object的发件人,Cirrious.MvvmCross.Binding.Bindings.Source.MvxSourcePropertyBindingEventArgs参数)
   在Cirrious.MvvmCross.Binding.Bindings.SourceSteps.MvxSourceStep.SendSourcePropertyChanged(布尔isAvailable,System.Object的值)
   在Cirrious.MvvmCross.Binding.Bindings.SourceSteps.MvxPathSourceStep.SourceBindingOnChanged(System.Object发件人,Cirrious.MvvmCross.Binding.Bindings.Source.MvxSourcePropertyBindingEventArgs参数)
   在Cirrious.MvvmCross.Binding.Bindings.Source.MvxSourceBinding.FireChanged(Cirrious.MvvmCross.Binding.Bindings.Source.MvxSourcePropertyBindingEventArgs参数)
   在Cirrious.MvvmCross.Binding.Bindings.Source.Leaf.MvxLeafPropertyInfoSourceBinding.OnBoundPropertyChanged()
   在Cirrious.MvvmCross.Binding.Bindings.Source.MvxPropertyInfoSourceBinding.SourcePropertyChanged(System.Object发件人,System.ComponentModel.PropertyChangedEventArgs E)
   在System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,System.Object的,System.Object的[],System.Exception的为ByRef)
   在System.Reflection.MonoMethod.Invoke(System.Object的OBJ,的BindingFlags invokeAttr,System.Reflection.Binder粘结剂,System.Object的[]参数,System.Globalization.CultureInfo文化)
   在System.Reflection.MethodBase.Invoke(System.Object的OBJ,System.Object的[]参数)
   在Cirrious.CrossCore.WeakSubscription.MvxWeakEventSubscription`2[[System.ComponentModel.INotifyPropertyChanged,系统,版本= 2.0.5.0,文化=中性公钥= 7cec85d7bea7798e],[System.ComponentModel.PropertyChangedEventArgs,系统,版本= 2.0.5.0,文化=中性公钥= 7cec85d7bea7798e]。OnSourceEvent(System.Object的发件人,系统.ComponentModel.PropertyChangedEventArgs五)
   在Cirrious.MvvmCross.ViewModels.MvxNotifyPropertyChanged+<>c__DisplayClass1.<RaisePropertyChanged>b__0()
   在Cirrious.CrossCore.Core.MvxMainThreadDispatcher.ExceptionMaskedAction(System.Action动作)
   在Cirrious.MvvmCross.Droid.Views.MvxAndroidMainThreadDispatcher+<>c__DisplayClass1.<RequestMainThreadAction>b__0(System.Object忽略)
   在Android.App.SyncContext + LT;邮政&GT; c__AnonStorey2E&LT;&GT; m__1F()的/Users/builder/data/lanes/monodroid-mlion-monodroid-4.8.0-branch/b76e8ec4/source/monodroid/src/Mono.Android/src/Android.App/SyncContext.cs:line 23
   在java.lang.Thread中的+ RunnableImplementor.Run()的/Users/builder/data/lanes/monodroid-mlion-monodroid-4.8.0-branch/b76e8ec4/source/monodroid/src/Mono.Android/src/Java.Lang/Thread.cs:line 32
   在Java.Lang.IRunnableInvoker.n_Run(IntPtr的JNIEnv的,IntPtr的native__this)在/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
   在System.Object.ea853478-e8d0-4bbe-8306-98c58e64097e(IntPtr的,IntPtr的)


解决方案

我不得不覆盖在视图中的 OnDestory()方法显示 MvxGridView

 公共覆盖无效的OnDestroy()
{
    MyProject.Core.ViewModel.MyViewModel VM = this.DataContext为MyProject.Core.ViewModel.MyViewModel;
    base.OnDestroy();
    vm.Implode();
}

接下来,我创建了一个看起来像这样的接口:

 公共接口IActiveViewModel
{
    ///&LT;总结&gt;
    ///用于明确处置的视图模型
    ///&LT; /总结&gt;
    无效爆();
}

在code的其余部分则在相应的视图模型 MyViewModel

新的接口类的粘性:

 公共类MyViewModel:MvxViewModel,IActiveViewModel

和这个功能添加到类,以及:

 公共无效爆()
{
    如果(MyGridTileViewModels!= NULL)
    {
        的foreach(GridTileViewModel VM在MyGridTileViewModels)
        {
            vm.Dispose();
        }
    }
    this.Dispose();
}

MyGridTileViewModels 是属性的 MvxGridView 势必会,它的定义是这样的:

 私人的ObservableCollection&LT; GridTileViewModel&GT; _myGridTileViewModels = NULL;公众的ObservableCollection&LT; GridTileViewModel&GT; MyGridTileViewModels
{
    {返回_myGridTileViewModels; }
    保护套
    {
        //设置数据,提高财产此处更改
    }
}

I'm working with a team to create an android application using MvvmCross. Recently we've started seeing a flood of repeating warning/error messages that look something like this:

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

These messages start about 3 minutes after switching away from a view that displays an MvxGridView. The MvxGridview is bound to a collection of view models, each with it's own bindings. The messages continue until the application is stopped. The UI gets increasingly sluggish as soon as the messages start, and eventually locks up completely. Interestingly, switching away from that screen seems to be the trigger. I can switch screens and then do nothing, for about 3 minutes, and the flood of messages will start flooding in. If I leave the app on that screen, everything runs smoothly.

Ultimately, I just want to know how to solve the issue so the app runs correctly. Some questions that might help reach that goal include:

  1. Is it possible to get a more detailed stack trace from MvvmCross? ANSWERED
  2. Do I need to manually dispose of the bindings in each cell of the MvxGridView like this: Clear bindings in MvvmCross? (The bindings bind automatically, so this might be off track.)


EDIT

This is the Environment.StackTrace variable from DebugTrace.cs. The stack trace for MvxTextViewTextTargetBinding and MvxWithEventPropertyInfoTargetBinding were exactly the same. (For readability, I removed the first few lines of the stack trace dealing with calling 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 )

解决方案

I had to override the OnDestory() method in the view that displays the MvxGridView.

public override void OnDestroy()
{
    MyProject.Core.ViewModel.MyViewModel vm = this.DataContext as MyProject.Core.ViewModel.MyViewModel;            
    base.OnDestroy();
    vm.Implode();
}

Next I created an interface that looks like this:

public interface IActiveViewModel
{
    /// <summary>
    /// Used to explicitly dispose of the viewModel
    /// </summary>
    void Implode();
}

The rest of the code goes in the associated View Model MyViewModel.

Tack on the new interface to class:

public class MyViewModel : MvxViewModel, IActiveViewModel

And add this function to the class as well:

public void Implode()
{
    if (MyGridTileViewModels != null)
    {
        foreach (GridTileViewModel vm in MyGridTileViewModels)
        {
            vm.Dispose();
        }
    }
    this.Dispose();
}

MyGridTileViewModels is the property the MvxGridView is bound to, and it is defined like this:

private ObservableCollection<GridTileViewModel> _myGridTileViewModels = null;

public ObservableCollection<GridTileViewModel> MyGridTileViewModels 
{
    get { return _myGridTileViewModels; }
    protected set
    {
        // Set data and raise property changed here
    }
}

这篇关于消息MvvmCross洪水:&QUOT;弱目标是在空... - 跳过集&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆