Bug 51238 - Transparent Grid causes Java.Lang.IllegalStateException: Unable to create layer for Platform_DefaultRenderer
Summary: Transparent Grid causes Java.Lang.IllegalStateException: Unable to create lay...
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android (show other bugs)
Version: 2.3.3
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
: 50662 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-01-05 14:20 UTC by Walter Olson
Modified: 2017-10-11 21:10 UTC (History)
22 users (show)

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


Attachments
Xamarin.Forms Android application that exhibits the Java.Lang.IllegalStateException crash (278.84 KB, application/x-zip-compressed)
2017-01-05 14:20 UTC, Walter Olson
Details

Description Walter Olson 2017-01-05 14:20:18 UTC
Created attachment 19097 [details]
Xamarin.Forms Android application that exhibits the Java.Lang.IllegalStateException crash

After upgrading from Xamarin.Forms 2.2.0.45 to 2.3.3.175 I experienced a crash on rendering several screens in my app.

I have narrowed it down to setting the opacity to a value below 1 on a Grid element. 
I also get the same error when setting the opacity to a value below 1 on a ContentView element where the content is a single Picker element(content set in code-behind).

I have tested with the following versions of Xamarin.Forms and found that the failure starts with version 2.3.3.163-pre3 and later.
2.2.0.45  - no crash
2.3.0.107 - no crash
2.3.1.114 - no crash
2.3.2.127 - no crash
2.3.3.152-pre2 - no crash
2.3.3.163-pre3 - CRASH Java.Lang.IllegalStateException
2.3.3.166-pre4 - CRASH Java.Lang.IllegalStateException
2.3.3.168 - CRASH Java.Lang.IllegalStateException
2.3.3.175 - CRASH Java.Lang.IllegalStateException

I have attached a sample application that has a grid with transparent Opacity setting which is set to isVisible = False when the app starts. When tapping the button, the visibility is set to true and the application crashes when trying to render the transparent Grid element.

The application would crash with the following error output in all cases:
W/OpenGLRenderer( 5007): Layer exceeds max. dimensions supported by the GPU (-4x-4, max=16384x16384)
D/OpenGLRenderer( 5007): Current memory usage / total memory usage (bytes):
D/OpenGLRenderer( 5007):   TextureCache                0 / 92274688
D/OpenGLRenderer( 5007):   LayerCache                  0 / 60817408 (numLayers = 0)
D/OpenGLRenderer( 5007):   Layers total          0 (numLayers = 0)
D/OpenGLRenderer( 5007):   RenderBufferCache           0 /  8388608
D/OpenGLRenderer( 5007):   GradientCache               0 /  2097152
D/OpenGLRenderer( 5007):   PathCache                   0 / 16777216
D/OpenGLRenderer( 5007):   TessellationCache        1488 /  1048576
D/OpenGLRenderer( 5007):   TextDropShadowCache         0 /  6291456
D/OpenGLRenderer( 5007):   PatchCache                  0 /   131072
D/OpenGLRenderer( 5007):   FontRenderer 0 A8     1048576 /  1048576
D/OpenGLRenderer( 5007):   FontRenderer 0 RGBA         0 /        0
D/OpenGLRenderer( 5007):   FontRenderer 0 total  1048576 /  1048576
D/OpenGLRenderer( 5007): Other:
D/OpenGLRenderer( 5007):   FboCache                    0 /       16
D/OpenGLRenderer( 5007): Total memory usage:
D/OpenGLRenderer( 5007):   1050064 bytes, 1.00 MB
D/AndroidRuntime( 5007): Shutting down VM
Unhandled Exception:

Java.Lang.IllegalStateException: Unable to create layer for Platform_DefaultRenderer

E/AndroidRuntime( 5007): FATAL EXCEPTION: main
E/AndroidRuntime( 5007): Process: TrasparentLayer22.Droid, PID: 5007
E/AndroidRuntime( 5007): java.lang.IllegalStateException: Unable to create layer for Platform_DefaultRenderer
E/AndroidRuntime( 5007): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/AndroidRuntime( 5007): 	at android.os.MessageQueue.next(MessageQueue.java:323)
E/AndroidRuntime( 5007): 	at android.os.Looper.loop(Looper.java:143)
E/AndroidRuntime( 5007): 	at android.app.ActivityThread.main(ActivityThread.java:7224)
E/AndroidRuntime( 5007): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 5007): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
E/AndroidRuntime( 5007): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Comment 1 Hrafn Loftsson 2017-01-10 11:51:20 UTC
I have encountered the same issue. A sample project is available here: https://github.com/KolibriDev/TestXFBugs

Xamarin.Forms 2.3.3.175: Navigate to the PinPage (by clicking the Login button on the LoginPage) and click the Confirmation button. On the next page (TransferConfirmedPage), click the Send notification button.  The following exception will occur: "Java.Lang.IllegalStateException: Unable to create layer for Platform_DefaultRenderer”. 

The TransferConfirmedPage uses the ModalShader class (a Grid).  In the constructor of the ModalShader, comment out the statement 'this.Opacity = 0.6'. By doing so, the app does not crash.

Xamarin.Forms 2.3.2.127: The above exception does not occur.
Comment 2 smorsi27 2017-01-19 14:08:26 UTC
I'm having the same issue after I upgraded from Xamarin Forms 2.1 to Xamarin 2.3.3.180! 

Anyone look into this. 

This is the exception I get for several pages: 

java.lang.IllegalStateException: Unable to create layer for Platform_DefaultRenderer
	at android.os.MessageQueue.nativePollOnce(Native Method)
	at android.os.MessageQueue.next(MessageQueue.java:323)
	at android.os.Looper.loop(Looper.java:143)
	at android.app.ActivityThread.main(ActivityThread.java:7229)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Comment 3 Adrian Ionita 2017-01-20 09:59:54 UTC
Same error.
I have tested: 2.3.3.168, 2.3.3.180 and 2.3.4.184-pre1

01-20 11:23:35.923 E/AndroidRuntime(24322): java.lang.IllegalStateException: Unable to create layer for Platform_DefaultRenderer
	at android.os.MessageQueue.nativePollOnce(Native Method)
	at android.os.MessageQueue.next(MessageQueue.java:323)
	at android.os.Looper.loop(Looper.java:143)
	at android.app.ActivityThread.main(ActivityThread.java:7229)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Comment 4 sh.naz 2017-01-20 13:15:51 UTC
Experiencing same error when setting opacity on a Frame. We are getting a lot of crash reports related to this issue.
Comment 5 smorsi27 2017-01-20 14:14:52 UTC
This issue is also semi-related to this: https://bugzilla.xamarin.com/show_bug.cgi?id=49168

In terms that it has to be with the visibility and opacity properties.
Comment 6 Gaëtan MARROT 2017-02-01 15:23:03 UTC
Experiencing same error with a StackLayout containing a Button with a fade in / fade out animation (using opacity) with Xamarin.Forms 2.3.3.180.

It crashes on Android >= 6.0.
Comment 7 Ashley Gazich [MSFT] 2017-02-07 22:35:24 UTC
I am able to replicate a crash using the sample from Comment 0 with Xamarin.Forms 2.3.4.192pre-2 on Samsung Galaxy S5, API 23.
Android emulator, iPhone 6, and iOS simulator were OK.


### Results

Java.Lang.IllegalStateException: Unable to create layer for Platform_DefaultRenderer
  at java.lang.IllegalStateException: Unable to create layer for Platform_DefaultRenderer
  at at android.os.MessageQueue.nativePollOnce(Native Method)
  at at android.os.MessageQueue.next(MessageQueue.java:323)
  at at android.os.Looper.loop(Looper.java:143)
  at at android.app.ActivityThread.main(ActivityThread.java:7224)
  at at java.lang.reflect.Method.invoke(Native Method)
  at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
  at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)


### Version information

=== Xamarin Studio Enterprise ===

Version 6.1.5 (build 0)
Installation UUID: bbb2aa5e-cc9f-46b8-8fd1-94319df9787c
Runtime:
	Mono 4.6.2 (mono-4.6.0-branch/ac9e222) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 406020016

=== NuGet ===

Version: 3.4.3.0

=== Xamarin.Profiler ===

Version: 1.1.8
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 8.2.1 (11766.1)
Build 8C1002

=== Xamarin.Android ===

Version: 7.0.2.42 (Visual Studio Enterprise)
Android SDK: /Users/ashleyg/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
		6.0    (API level 23)
		7.0    (API level 24)

SDK Tools Version: 25.2.5
SDK Platform Tools Version: 25.0.3
SDK Build Tools Version: 25.0.2

Java SDK: /usr
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin Android Player ===

Not Installed

=== Xamarin.iOS ===

Version: 10.3.1.8 (Visual Studio Enterprise)
Hash: 7beaef4
Branch: cycle8-xi
Build date: 2016-12-20 02:58:14-0500

=== Xamarin.Mac ===

Version: 2.10.0.120 (Visual Studio Enterprise)

=== Xamarin Inspector ===

Version: 1.0.0.0
Hash: 1f3067d
Branch: master
Build date: 11/15/2016 4:13:59 PM

=== Build Information ===

Release ID: 601050000
Git revision: 7494718e127af9eaec45a3bd6282d3da927488bd
Build date: 2017-01-17 10:31:01-05
Xamarin addins: c92d0626d347aaa02839689eaac2961d24c9f446
Build lane: monodevelop-lion-cycle8

=== Operating System ===

Mac OS X 10.11.6
Darwin ashleyg.local 15.6.0 Darwin Kernel Version 15.6.0
    Thu Jun 23 18:25:34 PDT 2016
    root:xnu-3248.60.10~1/RELEASE_X86_64 x86_64

=== Enabled user installed addins ===

Xamarin Inspector 1.0.0.0
Comment 8 dhaligas 2017-02-13 15:21:05 UTC
Hrafn Loftsson, Walter Olson  this issue is inheriting from Grid in your ModalShader class.  I ran into the same thing and then I changed my class to inherit from ContentView and it works.  

Not sure why inheriting from Grid causes this.
Comment 9 E.Z. Hart [MSFT] 2017-02-15 20:51:03 UTC
*** Bug 50662 has been marked as a duplicate of this bug. ***
Comment 10 FieldstrikeMobile 2017-02-17 15:16:16 UTC
Killer bug right here.

I am constantly turning on and off transparent layers
Comment 11 Akash 2017-02-22 06:51:27 UTC
this bug is really irritating i am using opacity because i don't want user to interact it with background screen..

When can we have resolution for it or anyone find a way out?
Comment 12 Jan Nepras 2017-02-22 15:43:28 UTC
Having the same issue and same question? Why it is taking too long to resolve that?
Comment 13 Hrafn Loftsson 2017-02-23 13:01:56 UTC
It is interesting that my bug does not occur in XF 2.3.3.180.
Comment 15 E.Z. Hart [MSFT] 2017-02-28 20:53:37 UTC
PR: https://github.com/xamarin/Xamarin.Forms/pull/785
Comment 16 Samantha Houts [MSFT] 2017-03-06 19:34:11 UTC
Should be fixed in 2.3.4-pre3. Thank you!
Comment 17 Sino Raj 2017-10-11 06:40:10 UTC
@samantha houts
Issue reproducible in Xamarin Forms 2.4.0.282. Please do needful ASAP. We didn't able to update package for newer Mono/Android Oreo release.
Comment 18 E.Z. Hart [MSFT] 2017-10-11 21:10:48 UTC
(In reply to Sino Raj from comment #17)
> @samantha houts
> Issue reproducible in Xamarin Forms 2.4.0.282. Please do needful ASAP. We
> didn't able to update package for newer Mono/Android Oreo release.

We've tried to reproduce this problem with 2.4.0.282, but it works fine in the attached reproduction project. 

Please verify that when you updated your project to 2.4.0 you fully deleted the `bin` and `obj` folders before rebuilding and running. If you're still experiencing the issue after that, please open a new Bugzilla issue.

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