dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.92k stars 526 forks source link

Listview binded to ObservableCollection crashes on Android when selecting item. #3198

Closed japero closed 4 years ago

japero commented 5 years ago

Description Listview binded to ObservableCollection shows data correctly but when selecting item OnItemTapped event crashes app. I added break to event handler but it is never reach.

Here is the datasource

public ObservableCollection ZoneCompinedInfos
{
    get { return zoneCompinedInfos; }
    set
    {
        zoneCompinedInfos = value;
        this.OnPropertyChanged();
    }
}

And here is how i fill it when data is updated.

ZoneCompinedInfos = new ObservableCollection(infos);

Of course I cannot show alldata due it is our app but this should give some idea?

Steps to Reproduce Listview binded to ObservableCollection() Listview shows data using DataTemplates to get binging to class properties. Selecting item crashes app. Expected Behavior App shows View dispalying details about selected item

Actual Behavior App crashes before hitting event handler break point.

Basic Information Version with issue: Latest stable Xamarin version 4.0.0.482894 Last known good version: 3.5.0.274416 works just fine IDE: Platform Target Frameworks: tested on Android iOS: Android: 8.1 UWP: Android Support Library Version: Nuget Packages: Affected Devices: Screenshots Reproduction Link error.txt

brendanzagaeski commented 5 years ago

Thanks for the report! Depending on which version of Visual Studio and the Xamarin.Android SDK you are using, I suspect you might be seeing https://github.com/xamarin/xamarin-android/issues/3112. To help confirm that, if you get a chance, if you could provide one of the following, that would be perfect:

Thanks in advance!

japero commented 5 years ago

Hi,

Sorry for late answer but attached is logcat exception. I cannot get this working no matter what I try. android kaatuminen.txt

japero commented 5 years ago

When I revert Xamarin nugets latest version to 3.5.0.274416 version problem dissappers!? I just cannot get my head arounf this one what is the reason for error.

brendanzagaeski commented 5 years ago

Thanks for the additional log file, and apologies for the slow reply! Interestingly, Android is logging this error a little differently than for the other similar unmanaged faults I've seen recently. For some reason, this one doesn't have a backtrace. But this new log file shows that the issue also happens for you on an arm ABI application. That means this issue will have a different root cause than https://github.com/xamarin/xamarin-android/issues/3112 because that issue only affects arm64 ABI applications.

06-20 13:23:46.670  Samsung SM-T719 Error   25389   DEBUG   signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0xff224fe0
    r0 00000000  r1 bfadac60  r2 c15efa48  r3 bf814c68
    r4 00000000  r5 bfadac60  r6 00000000  r7 00000003
    r8 bf814c68  r9 ee705900  sl 00000000  fp ffa205d0
    ip ed10c000  sp ff224ff0  lr c4b2b770  pc cf0e0a80  cpsr 600f0010
06-20 13:23:46.670  Samsung SM-T719 Error   25389   DEBUG   pid: 25179, tid: 25179, name: l.mobileContact  >>> fi.semel.mobileContact <<<
06-20 13:23:46.670  Samsung SM-T719 Error   25389   DEBUG   ABI: 'arm'
06-20 13:23:46.669  Samsung SM-T719 Error   25389   DEBUG   Revision: '5'
06-20 13:23:46.669  Samsung SM-T719 Error   25389   DEBUG   Build fingerprint: 'samsung/gts28veltexx/gts28velte:7.0/NRD90M/T719XXU2BSA1:user/release-keys'
06-20 13:23:46.669  Samsung SM-T719 Error   25389   DEBUG   *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
06-20 13:23:46.580  Samsung SM-T719 Warning 390     debuggerd: handling request: pid=25179 uid=11524 gid=11524 tid=25179
06-20 13:23:46.579  Samsung SM-T719 Error   25179   libc    Fatal signal 11 (SIGSEGV), code 2, fault addr 0xff224fe0 in tid 25179 (l.mobileContact)

As one possible next step, if you might have a project you can zip up and share that demonstrates this problem, that would be excellent. If attaching the project to this GitHub issue publicly won't work, then a few other options are:

Thanks in advance!

japero commented 5 years ago

Hi,

Long time since last message but I finally found out reason for this crash. I have a backgroud process taht receives messages and fires event that fills List with objects I created. I have made on some point Extender class for Ui to get IComparable and other stuff included and it "eats" this received object. Then on Ui I Binded labels etc. to this Extender class properties that provide only info from "master" object. Below is example. Class is defined like this:

public class ZoneCarInfoExtender : IEquatable<ZoneCarInfoExtender>, IComparable<ZoneCarInfoExtender>
{
        public readonly ZoneCarInformation zoneCarInformation;

        public int Zone
        {
            get
            {
                    return zoneCarInformation.Zone;
            }
        }
....

After removed this extender class from use due I do not need IComparable etc. The error above disappeared and detail view is show!!!! Hope this helps if someone want´s to find out reason for this behaviour.

Jarno