Bug 43150 - Unfortunately, System UI has stopped - Infinite popups after deploy to device
Summary: Unfortunately, System UI has stopped - Infinite popups after deploy to device
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.3.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Rui Marinho
URL:
Depends on:
Blocks:
 
Reported: 2016-08-06 21:35 UTC by Leo Reading
Modified: 2017-06-19 21:34 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Leo Reading 2016-08-06 21:35:08 UTC
Summary:

    After deploying an android build to my device, I begin getting an alert saying "Unfortunately, System UI has stopped".  As soon as you dismiss the alert, another alert with the same message is displayed.  This began happening after updating the drawable/icon in the application.  The application uses a Xamarin.Forms.MasterDetailPage, and has the MainActivity's Icon property set to drawable/icon

Device: Samsung Galaxy Note 5 (SM-N920V)

Android Version: 6.0.1

Xamarin.Forms Version: 2.3.0.107

Xamarin Version: 4.1.2.18

Visual Studio Community 2015: 14.0.25123.00 Update 2




Related Sources:

    There seems to be issues with this happening in Marshmallow, but mostly related to the "Force RTL Layout".
        http://forums.androidcentral.com/motorola-droid-turbo/551294-help-lollipop-unfortunately-system-ui-has-stopped-how-can-i-fix.html

    Clearing the cache partition (as suggested by related issues) did not resolve the issue.  The only way I have found to resolve it is by doing a factory reset on the device.




Steps to Reproduce:

    Unknown at this time.  I will attempt to create a MVCE if possible and report back.



Suspicions:

    The drawable resources may not have been scaled correctly, and this is causing something in Android to become corrupt.  If that is the case, it may well not be a Xamarin bug but an Android bug.  I am reporting here as this seems to be an appropriate starting point.
Comment 1 Leo Reading 2016-08-06 22:43:38 UTC
Setting the drawable/icon to a transparent color seems to have fixed the issue: https://forums.xamarin.com/discussion/34871/remove-icon-from-action-bar-from-xamarin-forms-android-project


This leads me to believe that it has to do with either the size or resolution of the image I am using.  I will still attempt to create a verifiable example and leave it to the Xamarin team to determine if it's something that Xamarin can/will address or if it's out of scope.
Comment 2 Leo Reading 2016-08-06 22:54:37 UTC
I have confirmed that it has to do with the image.  I made an example project with a massive drawable/icon, and removed the different scaled versions (hdpi/xhdpi etc)


ONLY RUN THIS PROJECT ON A DEVICE IF YOU'RE WILLING TO DO A FULL FACTORY RESET.  THIS WILL BREAK YOUR ANDROID INSTALL, AND THERE IS NO KNOWN SOLUTION.

Steps to reproduce:

    1) Download attachment (Xamarin.Forms Portable Solution)
    2) Debug the appliction
    3) After seeing the "Hello World" page, stop debugging

Expected Result:
    Android operating system continues as usual

Actual Result:
    Android operating system repeatedly displays alerts saying "Unfortunately, System UI has stopped".  This behavior persists even after rebooting and/or clearing the cache partition


Note: I did go a little overboard on the size of the icon image (which may be considered unrealistic), but the problem persists as smaller scales
Comment 3 Leo Reading 2016-08-06 22:59:11 UTC
Sorry for the multiple posts... The file is too large to add as an attachment.

https://www.dropbox.com/s/ij4fge2hbz6nczg/SystemUiXamarinBug.zip?dl=0
Comment 4 Rui Marinho 2016-08-10 12:29:34 UTC
Hi, did you try reproduce the issue in Xamarin.Android, not forms to see if its a platform issue?!
Comment 5 Leo Reading 2016-08-12 15:41:12 UTC
If you look at the example I sent, the issue seems to be with the Xamarin.Android project rather than with the Xamarin.Forms project (which is what I had initially suspected).

I will not be attempting to reproduce the issue any further, as I test with my actual cell phone and do not want to factory reset repeatedly.
Comment 6 Michael Davis 2017-01-23 16:30:48 UTC
I just ran into this bug using Xamarin.Forms. By accident, I also figured out how to break out of the "Unfortunately, System UI has stopped". 

In order to break out, you need to make an exception to occur in the MainActivity. In my case, I had a timer object being instantiated inside OnCreate that I commented out. Then in my OnResume method, I got a NullReferenceException. Oops...but it ended up fixing the crash loop!

Also of note - My app doesn't start crashing until I push the "Show Running Applications" button. At that point, I'm guessing it attempts to render the Icon and begins the crash.
Comment 7 Rui Marinho 2017-06-19 21:34:08 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Forms. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.

Here are some reproduction best practices: https://gist.github.com/jassmith/92405c300e54a01dcc6d