This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 55559 - [Android] Exception when setting the backgroundcolor of a frame
Summary: [Android] Exception when setting the backgroundcolor of a frame
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android (show other bugs)
Version: 2.3.4
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Jimmy
URL:
: 42025 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-04-25 13:33 UTC by GPS Security
Modified: 2017-07-14 15:51 UTC (History)
8 users (show)

See Also:
Tags: ac android crash frame backgroundcolor NullPointerException
Is this bug a regression?: ---
Last known good build:


Attachments
repro project (43.63 KB, application/x-zip-compressed)
2017-04-25 17:25 UTC, Jimmy
Details
Attached are the generated when issue is reproduced(Reopen) (4.05 KB, application/zip)
2017-06-29 10:52 UTC, Saurabh Paunikar
Details

Description GPS Security 2017-04-25 13:33:53 UTC
The same occurs when try to set the radius


04-25 15:15:46.787 I/MonoDroid(11865): UNHANDLED EXCEPTION:
04-25 15:15:46.830 I/MonoDroid(11865): Java.Lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isMutable()' on a null object reference
04-25 15:15:46.830 I/MonoDroid(11865):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
04-25 15:15:46.830 I/MonoDroid(11865):   at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x000a7] in /Users/builder/data/lanes/4468/b16fb820/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:12083 
04-25 15:15:46.830 I/MonoDroid(11865):   at Java.Interop.JniPeerMembers+JniInstanceMethods.FinishCreateInstance (System.String constructorSignature, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00060] in /Users/builder/data/lanes/4468/b16fb820/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods.cs:148 
04-25 15:15:46.830 I/MonoDroid(11865):   at Android.Graphics.Canvas..ctor (Android.Graphics.Bitmap bitmap) [0x00078] in /Users/builder/data/lanes/4468/b16fb820/source/monodroid/src/Mono.Android/platforms/android-25/src/generated/Android.Graphics.Canvas.cs:236 
04-25 15:15:46.830 I/MonoDroid(11865):   at Xamarin.Forms.Platform.Android.FrameRenderer+FrameDrawable.FrameOnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00045] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\FrameRenderer.cs:191 
04-25 15:15:46.830 I/MonoDroid(11865):   at (wrapper delegate-invoke) <Module>:invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs)
04-25 15:15:46.830 I/MonoDroid(11865):   at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x0000a] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:136 
04-25 15:15:46.830 I/MonoDroid(11865):   at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:380 
04-25 15:15:46.830 I/MonoDroid(11865):   at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.BindableObject+SetValueFlags attributes, System.Boolean silent) [0x000f4] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:589 
04-25 15:15:46.830 I/MonoDroid(11865):   at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.BindableObject+SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0015b] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:386 
04-25 15:15:46.830 I/MonoDroid(11865):   at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x0005f] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:539 
04-25 15:15:46.830 I/MonoDroid(11865):   at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:321 
04-25 15:15:46.830 I/MonoDroid(11865):   at Xamarin.Forms.Setter.Apply (Xamarin.Forms.BindableObject target, System.Boolean fromStyle) [0x00097] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Setter.cs:60 
04-25 15:15:46.830 I/MonoDroid(11865):   at Xamarin.Forms.TriggerBase.OnConditionChanged (Xamarin.Forms.BindableObject bindable, System.Boolean oldValue, System.Boolean newValue) [0x00045] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Interactivity\TriggerBase.cs:100 
04-25 15:15:46.830 I/MonoDroid(11865):   at Xamarin.Forms.PropertyCondition.OnStatePropertyChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00017] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Interactivity\PropertyCondition.cs:97 
04-25 15:15:46.830 I/MonoDroid(11865):   at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.BindableObject+SetValueFlags attributes, System.Boolean silent) [0x00108] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:592 
04-25 15:15:46.830 I/MonoDroid(11865):   at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.BindableObject+SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0015b] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:386 
04-25 15:15:46.830 I/MonoDroid(11865):   at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x0005f] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:539 
04-25 15:15:46.830 I/MonoDroid(11865):   at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:83 
04-25 15:15:46.830 I/MonoDroid(11865):   at Xamarin.Forms.PropertyCondition.OnAttachedObjectPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x0006b] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Interactivity\PropertyCondition.cs:88 
04-25 15:15:46.830 I/MonoDroid(11865):   at (wrapper delegate-invoke) <Module>:invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs)
04-25 15:15:46.830 I/MonoDroid(11865):   at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x0000a] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:136 
04-25 15:15:46.830 I/MonoDroid(11865):   at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:380 
04-25 15:15:46.830 I/MonoDroid(11865):   at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.BindableObject+SetValueFlags attributes, System.Boolean silent) [0x000f4] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:589 
04-25 15:15:46.830 I/MonoDroid(11865):   at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.BindableObject+SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0015b] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:386 
04-25 15:15:46.830 I/MonoDroid(11865):   at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x001f9] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:173 
04-25 15:15:46.830 I/MonoDroid(11865):   at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:55 
04-25 15:15:46.830 I/MonoDroid(11865):   at Xamarin.Forms.BindingExpression+BindingExpressionPart.<PropertyChanged>b__47_0 () [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:539 
04-25 15:15:46.830 I/MonoDroid(11865):   at Java.Lang.Thread+RunnableImplementor.Run () [0x0000b] in /Users/builder/data/lanes/4468/b16fb820/source/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36 
04-25 15:15:46.830 I/MonoDroid(11865):   at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in /Users/builder/data/lanes/4468/b16fb820/source/monodroid/src/Mono.Android/platforms/android-25/src/generated/Java.Lang.IRunnable.cs:81 
04-25 15:15:46.830 I/MonoDroid(11865):   at (wrapper dynamic-method) System.Object:f3637ea1-4d38-4374-ae5e-4151f197a74c (intptr,intptr)
04-25 15:15:46.830 I/MonoDroid(11865):   --- End of managed Java.Lang.NullPointerException stack trace ---
04-25 15:15:46.830 I/MonoDroid(11865): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isMutable()' on a null object reference
04-25 15:15:46.830 I/MonoDroid(11865): 	at android.graphics.Canvas.<init>(Canvas.java:130)
04-25 15:15:46.830 I/MonoDroid(11865): 	at mono.java.lang.RunnableImplementor.n_run(Native Method)
04-25 15:15:46.831 I/MonoDroid(11865): 	at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
04-25 15:15:46.831 I/MonoDroid(11865): 	at android.os.Handler.handleCallback(Handler.java:751)
04-25 15:15:46.831 I/MonoDroid(11865): 	at android.os.Handler.dispatchMessage(Handler.java:95)
04-25 15:15:46.831 I/MonoDroid(11865): 	at android.os.Looper.loop(Looper.java:154)
04-25 15:15:46.831 I/MonoDroid(11865): 	at android.app.ActivityThread.main(ActivityThread.java:6119)
04-25 15:15:46.831 I/MonoDroid(11865): 	at java.lang.reflect.Method.invoke(Native Method)
04-25 15:15:46.831 I/MonoDroid(11865): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
04-25 15:15:46.831 I/MonoDroid(11865): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Comment 1 Jimmy 2017-04-25 17:25:27 UTC
Created attachment 21771 [details]
repro project

This is a duplicate of bug 42025 however that report is private. 

I was able to reproduce this with the project I am attaching. This crash is occurring whenever you try changing the background of a Frame and are using FormsApplicationActivity.

I tested on a Android 6.0 device and 4.4 emulator.

Full debug output: https://gist.github.com/jimmgarrido/b79274edcecd3fb7f3bccd5fefbc1da8


### Steps to reproduce
1. Run the attached project
2. Press "Change Frame Background"


### Expected Results
The Frame will have a red Background


### Actual Results
The app will crash.


### Workaround
You can use FormsAppCompatActivity instead of FormsApplicationActivity: https://developer.xamarin.com/guides/xamarin-forms/platform-features/android/appcompat/
Comment 2 Rui Marinho 2017-05-04 14:13:01 UTC
Should be fixed in 2.3.5-pre3
Comment 6 Jimmy 2017-07-11 23:02:55 UTC
*** Bug 42025 has been marked as a duplicate of this bug. ***
Comment 7 Saurabh Paunikar 2017-07-12 06:59:18 UTC
Verified on xamarin.form version 2.3.5.256-pre6.
ScreenCast Link : https://www.screencast.com/t/PDd4MlyMJUo
Comment 8 John Hair 2017-07-14 15:35:24 UTC
I can confirm that pre6 fixes the crash, however the CornerRadius (if it has been set on the frame) is ignored.
Comment 9 John Hair 2017-07-14 15:51:28 UTC
To clarify, CornerRadius is ignored after BackgroundColor is set after the initial display of the Frame

Note You need to log in before you can comment on or make changes to this bug.