Android Question UnsupportedOperationException (@GLES20Canvas:drawPicture...)

peacemaker

Expert
Licensed User
Longtime User
Why such error can occure ?
It's my app that uses OSMDROID map lib, that uses lots of memory, as i can imagine.

Manifest now is so:
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="11" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true"
    android:smallScreens="false"
    android:normalScreens="true"
    android:xlargeScreens="true"
    android:resizeable="true"
    android:requiresSmallestWidthDp="480"
    android:anyDensity="true"/>)

AddManifestText(<uses-feature android:name="android.hardware.location.gps" android:required="false" />)
AddManifestText(<uses-feature android:name="android.hardware.location" android:required="false"/>)
AddManifestText(<uses-feature android:name="android.hardware.location.network" android:required="false"/>)
AddApplicationText(<activity android:name="de.amberhome.objects.preferenceactivity"/>)
SetManifestAttribute("android:installLocation", "auto")
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:hardwareAccelerated, "false")
SetApplicationAttribute(android:isGame, "true")
SetApplicationAttribute(android:largeHeap, "true")

Error occurs only under Android 4.0.3 and 4.0.4.
Can it be caught ? Or avoided by manifest settings?

And second error set is about OutOfMemory that occurs in various subs, any Android versions, and even on 2GB device (Sony). Can it be caught ?
 
Last edited:

peacemaker

Expert
Licensed User
Longtime User
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
BTW, i have tried Accelerated surface lib, Informatix:
B4X:
Dim sa As AcceleratedSurface
sa.Initialize("", True)
Log("IsHardwareAccelerated=" & sa.IsHardwareAccelerated)

Result is always false :-(, on any of 2 devices and PC emulator, and with any manifest settings (true or false). But one device is Android 4.0.3 that has this error (UnsupportedOperationException (@GLES20Canvas:drawPicture...)), others work OK.

How detect for sure if the device is accelerated ? :-(
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
BTW, i have tried Accelerated surface lib, Informatix:
B4X:
Dim sa As AcceleratedSurface
sa.Initialize("", True)
Log("IsHardwareAccelerated=" & sa.IsHardwareAccelerated)

Result is always false :-(, on any of 2 devices and PC emulator, and with any manifest settings (true or false). But one device is Android 4.0.3 that has this error (UnsupportedOperationException (@GLES20Canvas:drawPicture...)), others work OK.

How detect for sure if the device is accelerated ? :-(
Good test. On the emulator, False is normal. On your devices, it's normal with Android versions < 3, but not with Android versions >= 3, except if there's no OpenGL driver on the device or a defective one (very very uncommon case). To be sure there's no mistake somewhere, could you send the little project you used to do this test?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
But this is whole test code in Sub Activity_Create(FirstTime As Boolean), stopped just after Log.
And both my real devices are 4.0 (with UnsupportedOperationException (@GLES20Canvas) error) and 4.2 - that is always OK working, but both are
sa.IsHardwareAccelerated = false any time :-(

Devices description is in my signature under post.
Does you lib use Canvas.isHardwareAccelerated ?
 
Last edited:
Upvote 0

Informatix

Expert
Licensed User
Longtime User
But this is whole test code in Sub Activity_Create(FirstTime As Boolean), stopped just after Log.
And both my real devices are 4.0 (with UnsupportedOperationException (@GLES20Canvas) error) and 4.2 - that is always OK working, but both are
sa.IsHardwareAccelerated = false any time :-(

Devices description is in my signature under post.
Does you lib use Canvas.isHardwareAccelerated ?
Could you send the project?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Android 4.2 1 GB:
B4X:
** Activity (main) Create, isFirst = true **
freeMemory=0.02590179443359375
free memory res =246.87356567382813
IsHardwareAccelerated=false

Android 4.0.3 512 MB:
B4X:
** Activity (main) Create, isFirst = true **
freeMemory=0.8890380859375
free memory res =118.88514709472656
IsHardwareAccelerated=false

Test code is attached:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
Log("free memory res =" & Get_FreeMem)

Dim sa As AcceleratedSurface
sa.Initialize("", True)
Log("IsHardwareAccelerated=" & sa.IsHardwareAccelerated)
ExitApplication

End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub


Sub Get_FreeMem As Float
   Dim r As Reflector
   Dim MM, TM, FM, Total As Int
   r.Target = r.RunStaticMethod("java.lang.Runtime", "getRuntime", Null, Null)
   MM = r.RunMethod("maxMemory")
   FM = r.RunMethod("freeMemory")
   Log("freeMemory=" & (FM/1024/1024))
   TM = r.RunMethod("totalMemory")
   Total = MM + FM - TM
   Return Total / 1024 / 1024
End Sub
 

Attachments

  • 1.zip
    6.6 KB · Views: 253
Last edited:
Upvote 0

Informatix

Expert
Licensed User
Longtime User
To make your code work, I had to remove a line in the manifest preventing me from compiling:
SetApplicationAttribute(android:isGame, "true")
and add a missing line in your code just before Log(...):
Activity.AddView(sa, 0, 0, -1, -1)

If you don't add the view to the activity, there's no need to accelerate anything.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Thanks for test, Informatix.
But i have retested also with extra code line and now
1) if Manifest requires "android:hardwareAccelerated = true" - both my devices (your surface) are IsHardwareAccelerated=TRUE
2) if Manifest requires "android:hardwareAccelerated = FALSE" - both my devices (your surface) are IsHardwareAccelerated=FALSE

It looks like that this error is kind of OutOfMemory error, i have posted: https://www.b4x.com/android/forum/threads/is-out-of-memory.50047/#post-312744

Despite that largeheap is requested in Manifest :-(
But app requires about 10-12 MB RAM only, if to check FreeMemory digits at start and after all is loaded\inited.
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
But if even IsHardwareAccelerated=TRUE under Android 4.0 -
UnsupportedOperationException (@GLES20Canvas) error is anyway here :-(((((

B4X:
LogCat connected to: "CKT TUNA"
--------- beginning of /dev/log/system


--------- beginning of /dev/log/main


** Activity (main) Create, isFirst = true **


free memory=0.1626129150390625


IsHardwareAccelerated=true


ru
** Activity (main) Resume **


java.lang.UnsupportedOperationException


    at android.view.GLES20Canvas.drawPicture(GLES20Canvas.java:905)
    at uk.co.martinpearman.b4a.osmdroid.views.overlays.MyScaleBarOverlay.draw(MyScaleBarOverlay.java:286)
    at org.osmdroid.views.overlay.OverlayManager.onDraw(OverlayManager.java:119)
    at org.osmdroid.views.MapView.dispatchDraw(MapView.java:901)
    at android.view.View.getDisplayList(View.java:10452)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2681)
    at android.view.View.getDisplayList(View.java:10417)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2681)
    at android.view.View.getDisplayList(View.java:10417)
    at android.view.ViewGroup.drawChild(ViewGroup.java:2934)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2573)
    at android.view.View.getDisplayList(View.java:10452)
    at android.view.ViewGroup.drawChild(ViewGroup.java:2934)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2573)
    at android.view.View.draw(View.java:11018)
    at android.widget.FrameLayout.draw(FrameLayout.java:450)
    at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2140)
    at android.view.View.getDisplayList(View.java:10454)
    at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:851)
    at android.view.ViewRootImpl.draw(ViewRootImpl.java:2034)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1748)
    at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2583)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4503)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
N
But if even IsHardwareAccelerated=TRUE under Android 4.0 -
UnsupportedOperationException (@GLES20Canvas) error is anyway here :-(((((

B4X:
LogCat connected to: "CKT TUNA"
--------- beginning of /dev/log/system


--------- beginning of /dev/log/main


** Activity (main) Create, isFirst = true **


free memory=0.1626129150390625


IsHardwareAccelerated=true


ru
** Activity (main) Resume **


java.lang.UnsupportedOperationException


    at android.view.GLES20Canvas.drawPicture(GLES20Canvas.java:905)
    at uk.co.martinpearman.b4a.osmdroid.views.overlays.MyScaleBarOverlay.draw(MyScaleBarOverlay.java:286)
    at org.osmdroid.views.overlay.OverlayManager.onDraw(OverlayManager.java:119)
    at org.osmdroid.views.MapView.dispatchDraw(MapView.java:901)
    at android.view.View.getDisplayList(View.java:10452)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2681)
    at android.view.View.getDisplayList(View.java:10417)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2681)
    at android.view.View.getDisplayList(View.java:10417)
    at android.view.ViewGroup.drawChild(ViewGroup.java:2934)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2573)
    at android.view.View.getDisplayList(View.java:10452)
    at android.view.ViewGroup.drawChild(ViewGroup.java:2934)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2573)
    at android.view.View.draw(View.java:11018)
    at android.widget.FrameLayout.draw(FrameLayout.java:450)
    at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2140)
    at android.view.View.getDisplayList(View.java:10454)
    at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:851)
    at android.view.ViewRootImpl.draw(ViewRootImpl.java:2034)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1748)
    at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2583)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4503)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
Note that you tested with my library and this test only proved that the view created by my library can benefit from the hardware acceleration on the device. Depending on how the other library enables the hardware acceleration, the view that it creates might be not accelerated at all. Without the code of your project and the code of the other library, it's difficult to have a certainty about your problem. Your device supports the hardware acceleration and you know how to enable the hardware acceleration in the manifest, so the bug comes probably from the library.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Maybe you are right.
But the app is not so popular (it uses OSMDROID that is big, complex...), so, i'm fishing the digging.
My app is like game, uses big lot of libraries - so, memory is important.
Thanks for reply.
 
Upvote 0
Top