Идентификатор условия утверждения не встречен - Xamarin - PullRequest
0 голосов
/ 26 сентября 2018

У меня есть представление списка, в котором есть заголовок шаблона, и каждая строка представляет собой пользовательский элемент управления, который отображает представление переработчика для Android.

Иногда, когда я обновляю наблюдаемую коллекцию, к которой привязан список, я получаю следующее

09-26 09: 58: 12.759 F / (19698): * Утверждение в / Users / builder / data / lanes / 6090 / 86d33f45 / source / monodroid / external / xamarin-android / external /mono / mono / metadata / sgen-tarjan-bridge.c: 1140, условие xref_count == xref_index' not met 09-26 09:58:12.764 F/libc (19698): Fatal signal 6 (SIGABRT), code -6 in tid 19822 (Thread Pool Wor), pid 19698 (houseofcode.Mir) 09-26 09:58:12.914 I/crash_dump32(20062): obtaining output fd from tombstoned, type: kDebuggerdTombstone 09-26 09:58:12.916 I//system/bin/tombstoned( 1483): received crash request for pid 19698 09-26 09:58:12.920 I/crash_dump32(20062): performing dump of process 19698 (target tid = 19822) 09-26 09:58:12.922 F/DEBUG (20062): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 09-26 09:58:12.922 F/DEBUG (20062): Build fingerprint: 'google/sdk_gphone_x86/generic_x86:8.1.0/OSM1.180201.007/4586646:user/release-keys' 09-26 09:58:12.922 F/DEBUG (20062): Revision: '0' 09-26 09:58:12.922 F/DEBUG (20062): ABI: 'x86' 09-26 09:58:12.922 F/DEBUG (20062): pid: 19698, tid: 19822, name: Thread Pool Wor >>> io.houseofcode.Mir <<< 09-26 09:58:12.922 F/DEBUG (20062): signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr -------- 09-26 09:58:12.923 F/DEBUG (20062): Abort message: '* Assertion at /Users/builder/data/lanes/6090/86d33f45/source/monodroid/external/xamarin-android/external/mono/mono/metadata/sgen-tarjan-bridge.c:1140, condition xref_count == xref_index 'не выполнено 09-26 09: 58: 12.923 F / DEBUG (20062):' 09-26 09:58:12.923 F / DEBUG (20062): eax 00000000 ebx 00004cf2 ecx 00004d6e edx 00000006 09-26 09: 58: 12.923 F / DEBUG (20062): esi 00000000 edi 00004cf2 09-26 09: 58: 12.923 F / DEBUG (20062):xcs 00000073 xds 0000007b xes 0000007b xfs 0000003b xss 0000007b 09-26 09: 58: 12.923 F / DEBUG (20062): eip b040dac4 ebp 00000000 esp 7d0fdd28 flags 00200286 09-26 09: 58: 12.926 F / DEBUG (20062): 09-26 09: 58: 12.926 F / DEBUG (20062): обратная трасса: 09-26 09: 58: 12.926 F / DEBUG (20062): # 00 pc 00000ac4 [vdso: b040d000] (__kernel_vsyscall + 16) 09-26 09: 58: 12.926 F / DEBUG (20062): # 01 pc 0001edf8 /system/lib/libc.so (syscall + 40) 09-26 09:58:12.926 F / DEBUG (20062): # 02 pc 0001f073 /system/lib/libc.so (abort + 115) 09-26 09: 58: 12.926 F / DEBUG (20062): # 03 pc 00295345 / data / app / Mono.Android.DebugRuntime-FonMYGn1d4jnoxtVxgxnRg == / lib / x86 / libmonosgen-32bit-2.0.so 09-26 09: 58: 13.547 W / zygote (1593): ошибка kill (-14436, 9): нет такого процесса 09-2609: 58: 13.547 I / zygote (1593): успешно убит идентификатор процесса cgroup uid 10053 pid 14436 в 1 мс 09-26 09: 58: 13.549 I / ActivityManager (1593): процесс com.google.android.apps.docs (pid 14436)) умер: cch + 6CEM 09-26 09: 58: 13.684 W / Looper (1593): отправка заняла 112 мс на android.ui, h = обработчик (com.android.server.am.ActivityManagerService $ UiHandler) {d9bb478} cb= null msg = 53 09-26 09: 58: 13.853 E // system / bin / tombstoned (1483): Tombstone записывается в: / data / tombstones / tombstone_00 09-26 09: 58: 13.883 I / BootReceiver (1593):Копирование / данные / надгробия / надгробие_00 в DropBox (SYSTEM_TOMBSTONE) 09-26 09: 58: 13.914 W / ActivityManager (1593): принудительно завершить действие io.houseofcode.Mir / md558c489633a57fe94a7e603acc8e0c63b.MainActivity 09-26 09: 58: 13.973 W / InputDispatcher (1593): 1593).houseofcode.Mir / md558c489633a57fe94a7e603acc8e0c63b.MainActivity (server) '~ Потребитель закрыл входной канал или произошла ошибка.events = 0xd 09-26 09: 58: 13.973 E / InputDispatcher (1593): канал '81391ff io.houseofcode.Mir / md558c489633a57fe94a7e603acc8e0c63b.MainActivity (server)' ~ Канал неисправим и сломан!09-26 09: 58: 13.981 I / Zygote (1466): процесс 19698 завершен из-за сигнала (6) 09-26 09: 58: 13.992 I / WindowManager (1593): WIN DEATH: Window {81391ff u0 io.houseofcode.Mir / md558c489633a57fe94a7e603acc8e0c63b.MainActivity} 09-26 09: 58: 13.992 W / InputDispatcher (1593): предпринята попытка отменить регистрацию уже незарегистрированного входного канала '81391ff io.houseofcode.Mir / md558c4896330aeeejb0688e63b8a6 (095) 095: 563e63b87014.005 W / ActivityManager (1593): исключение, генерируемое во время паузы 09-26 09: 58: 14.005 W / ActivityManager (1593): android.os.DeadObjectException 09-26 09: 58: 14.005 W / ActivityManager (1593): на андроиде.os.BinderProxy.transactNative (собственный метод) 09-26 09: 58: 14.005 W / ActivityManager (1593): на android.os.BinderProxy.transact (Binder.java:764) 09-26 09: 58: 14.005 W / ActivityManager(1593): в android.app.IApplicationThread $ Stub $ Proxy.schedulePauseActivity (IApplicationThread.java:1079) 09-26 09: 58: 14.005 W / ActivityManager (1593): в com.android.server.am.ActivityStack.startPausingLocked (ActivityStack.java:1347) 09-26 09: 58: 14.005 W / ActivityManager (1593): на com.android.server.am.ActivityStack.finishActivityLocked (ActivityStack.java:3779)09-26 09: 58: 14.005 W / ActivityManager (1593): на com.android.server.am.ActivityStack.finishActivityLocked (ActivityStack.java:3721) 09-26 09: 58: 14.005 W / ActivityManager (1593): вcom.android.server.am.ActivityStack.finishTopRunningActivityLocked (ActivityStack.java:3602) 09-26 09: 58: 14.005 W / ActivityManager (1593): по адресу com.android.server.am.ActivityStackSupervisor.finishTopRunningActivityLocked (ActivityStacker.jscked: ActivityStacker_j2124) 09-26 09: 58: 14.005 W / ActivityManager (1593): на com.android.server.am.AppErrors.handleAppCrashLocked (AppErrors.java:668) 09-26 09: 58: 14.005 W / ActivityManager (1593): в com.android.server.am.AppErrors.makeAppCrashingLocked (AppErrors.java:500) 09-26 09: 58: 14.005 W / ActivityManager (1593): в com.android.server.am.AppErrors.crashApplicationInner (AppErrors.Java: 376) 09-26 09: 58: 14.005 W / ActivityManager (1593): at com.android.server.am.AppErrors.crashApplication (AppErrors.java:321) 09-26 09: 58: 14.005 W / ActivityManager (1593): на com.android.server.am.ActivityManagerSerVice.handleApplicationCrashInner (ActivityManagerService.java:14375) 09-26 09: 58: 14.005 W / ActivityManager (1593): в com.android.server.am.NativeCrashListener $ NativeCrashReporter.run (NativeCrashListener.java:85) 09-26: 58: 14.015 D / ConnectivityService (1593): Служба ConnectivityService NetworkRequestInfo): Ошибка открытия / proc / 19698 / oom_score_adj;errno = 2 09-26 09: 58: 14.067 I / ActivityManager (1593): процесс io.houseofcode.Mir (pid 19698) умер: vis + 99TOP 09-26 09: 58: 14.069 W / zygote (1593): убить(-19698, 9) сбой: такой процесс отсутствует 09-26 09: 58: 14.069 I / zygote (1593): успешно уничтоженный процесс cgroup uid 10108 pid 19698 за 1 мс 09-26 09: 58: 14.100 D / gralloc_ranchu (1395): gralloc_alloc: создание области пепла размером 8298496 09-26 09: 58: 14.108 W / ActivityManager (1593): setHasOverlayUi вызвал неизвестный pid: 19698 09-26 09: 58: 14.130 I / ActivityManager (1593): отображение диалогового окна сбоя дляпакет io.houseofcode.Mir u0

это мой список просмотра

<ListView x:Name="lstVideos" SeparatorVisibility="None" ItemsSource="{Binding Videos}" HasUnevenRows="true">
   <ListView.Header>
                <Grid x:Name="vwFeatured" VerticalOptions="StartAndExpand" HeightRequest="180">
                    <Grid.GestureRecognizers>
                        <TapGestureRecognizer Command="{Binding ShowVideoCommand}" CommandParameter="{Binding FeaturedVideo}"></TapGestureRecognizer>
                    </Grid.GestureRecognizers>
                    <Image x:Name="imgFeatured" BackgroundColor="DimGray" Aspect="Fill" Source="{Binding FeaturedVideo.Thumbnail}" 
                                                 VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
                    </Image>
                    <Image Source="Play" IsVisible="{Binding FeaturedVideo.FullyDownloaded}" VerticalOptions="Center" HorizontalOptions="Center">
                    </Image>

             <Label Text="Loading..." FontSize="Medium" TextColor="White" IsVisible="{Binding FeaturedVideo.FullyDownloaded, Converter={StaticResource InverseBoolConverter}}" 
                           VerticalOptions="Center" HorizontalOptions="Center"></Label>
                </Grid>
     </ListView.Header>
     <ListView.ItemTemplate>
                <DataTemplate>
                    <controls2:TransparentCell>
                        <StackLayout Margin="0, 10">
                    <StackLayout  HorizontalOptions="Fill" Orientation="Horizontal">
                        <Label Text="{Binding SectionName}" VerticalOptions="Fill" VerticalTextAlignment="Center" HorizontalOptions="Start" Style="{StaticResource SectionHeaderStyle}" Margin="10,10">
                       </Label>
                       <Label Text="{Binding VideoCount, StringFormat='{0:D} videos'}" VerticalTextAlignment="Center" VerticalOptions="Fill" HorizontalOptions="EndAndExpand" Style="{StaticResource VideoCountStyle}" Margin="10,10">
                       </Label>
                 </StackLayout>
                 <controls:XfGridView x:Name="vwVideos" ItemsSource="{Binding VideoData}" Orientation="Horizontal" ItemTemplate="{StaticResource videoTemplate}" 
                                                 ColumnSpacing="15" RowSpacing="5" ItemWidth="145" ItemHeight="120">
                      </controls:XfGridView>
                  </StackLayout>
              </controls2:TransparentCell>
           </DataTemplate>
       </ListView.ItemTemplate>
  </ListView>

и это мой пользовательский рендерер

    public class XfGridRenderer : ViewRenderer<XfGridView, RecyclerView>
    {

    protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
    {
        if (Element.ItemsSource != null)
        {
            int count = 0;
            foreach (var item in Element.ItemsSource)
                count++;

        }

        var recyclerView = new RecyclerView(Context);

        int orientation = (Element.Orientation == Controls.GridOrientation.Horizontal) ? OrientationHelper.Horizontal : OrientationHelper.Vertical;
        recyclerView.SetLayoutManager(new GridLayoutManager(Context, Element.NoOfColumns, orientation, false));

        recyclerView.AddItemDecoration(new RecyclerItemDecoration((int)Element.RowSpacing, (int)Element.ColumnSpacing, (int)Element.NoOfColumns, orientation));
                SetNativeControl(recyclerView);
                var adapter = new RecycleViewAdapter(Element);
                Control.SetAdapter(adapter);


    }

    protected override void OnElementChanged(ElementChangedEventArgs<XfGridView> e)
    {
        base.OnElementChanged(e);

        if ((Element.Orientation == Controls.GridOrientation.Vertical))
            Element.WidthRequest = Element.NoOfColumns * Element.ItemWidth;
        else
            Element.HeightRequest = Element.NoOfColumns * Element.ItemHeight;

    }


}

public class RecycleViewAdapter : RecyclerView.Adapter
{
    private readonly XfGridView _view;

    private readonly IList _dataSource;

    public override int ItemCount => (_dataSource != null ? _dataSource.Count : 0);

    public override long GetItemId(int position)
    {
        return position;
    }

    public RecycleViewAdapter(XfGridView view)
    {
        _view = view;
        _dataSource = view.ItemsSource?.Cast<object>()?.ToList();
        HasStableIds = true;
    }

    public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
    {
        var item = (RecycleViewHolder)holder;
        var dataContext = _dataSource[position];

        item.SetBindingItems(dataContext, _view);

    }

    public override void OnViewAttachedToWindow(Java.Lang.Object holder)
    {
        base.OnViewAttachedToWindow(holder);
        var item = (RecycleViewHolder)holder;
        item.UpdateUi();

    }
    public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
    {
        var contentFrame = new FrameLayout(parent.Context)
        {
            LayoutParameters = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent,
                                                            ViewGroup.LayoutParams.WrapContent)
            {
                Height = (int)(_view.ItemHeight * Resources.System.DisplayMetrics.Density),
                Width = (int)(_view.ItemWidth * Resources.System.DisplayMetrics.Density)
            }
        };

        contentFrame.DescendantFocusability = DescendantFocusability.BeforeDescendants;
        var viewHolder = new RecycleViewHolder(contentFrame);
        return viewHolder;
    }

}


public class RecycleViewHolder : RecyclerView.ViewHolder
{
    private ViewCell _viewCell;
    private object _dataContext;
    private XfGridView _view;

    public RecycleViewHolder(Android.Views.View itemView) : base(itemView)
    {
        ItemView = itemView;
    }

    public void SetBindingItems(object dataContext, XfGridView view)
    {
        _dataContext = dataContext;
        _view = view;
    }
    public void UpdateUi()
    {
        if (_dataContext != null)
        {
            var dataTemplate = _view.ItemTemplate;

            var selector = dataTemplate as DataTemplateSelector;
            if (selector != null)
            {
                var template = selector.SelectTemplate(_dataContext, _view.Parent);
                _viewCell = template.CreateContent() as ViewCell;
            }
            else
            {
                _viewCell = dataTemplate?.CreateContent() as ViewCell;
            }
        }

        var contentLayout = (FrameLayout)ItemView;

        _viewCell.BindingContext = _dataContext;
        _viewCell.Parent = _view;

        var metrics = Resources.System.DisplayMetrics;
        var height = (int)((_view.ItemWidth + _viewCell.View.Margin.Top + _viewCell.View.Margin.Bottom) * metrics.Density);
        var width = (int)((_view.ItemWidth + _viewCell.View.Margin.Left + _viewCell.View.Margin.Right) * metrics.Density);

        _viewCell.View.Layout(new Rectangle(0, 0, _view.ItemWidth, _view.ItemHeight));


        var layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent)
        {
            Height = height,
            Width = width
        };

        if (Platform.GetRenderer(_viewCell.View) == null)
        {
            Platform.SetRenderer(_viewCell.View, Platform.CreateRenderer(_viewCell.View));
        }

        var renderer = Platform.GetRenderer(_viewCell.View);

        var viewGroup = renderer.View;
        viewGroup.LayoutParameters = layoutParams;
        viewGroup.Layout(0, 0, (int)_view.ItemWidth, (int)_view.ItemHeight);

        contentLayout.RemoveAllViews();
        contentLayout.AddView(viewGroup);
    }
}

public class RecyclerItemDecoration : RecyclerView.ItemDecoration
{
    private int _rowSpacing;
    private int _colSpacing;
    private int _noOfColumns;
    private int _orientation;
    public RecyclerItemDecoration(int rowSpacing, int colSpacing, int colNo, int orientation)
    {
        _rowSpacing = (int)(rowSpacing * Resources.System.DisplayMetrics.Density);
        _colSpacing = (int)(colSpacing * Resources.System.DisplayMetrics.Density);
        _noOfColumns = colNo;
        _orientation = orientation;
    }
    public override void GetItemOffsets(Rect outRect, Android.Views.View view, RecyclerView parent, RecyclerView.State state)
    {
        base.GetItemOffsets(outRect, view, parent, state);

        outRect.Right = _colSpacing;
        outRect.Bottom = _rowSpacing;
        int position = parent.GetChildLayoutPosition(view);

        if (_orientation == OrientationHelper.Vertical)
        {
            if (position < _noOfColumns)
            {
                outRect.Top = _rowSpacing;
            }
            else
            {
                outRect.Top = 0;
            }
            if ((position % _noOfColumns) == 0)
            {
                outRect.Left = _colSpacing;
            }
            else
            {
                outRect.Left = _colSpacing / 2;
            }
        }
        else
        {
            if ((position % _noOfColumns) == 0)
            {
                outRect.Top = _rowSpacing;
            }
            else
            {
                outRect.Top = _rowSpacing / 2;
            }
            if (position < _noOfColumns)
            {
                outRect.Left = _colSpacing;
            }
            else
            {
                outRect.Left = 0;
            }
        }

    }
}

1 Ответ

0 голосов
/ 11 октября 2018

Что на самом деле сработало, так это сменив GC на старый от Tarjan, добавив эту строку в среду Android

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...