Jump to content
TomDevOps

Android app - hardware acceleration for the form

Recommended Posts

All,

 

Does any one know how to enable hardware acceleration for the view (form)? All I know so fat is I can have acceleration setup at the application level or at the activity level (Android manifest). Also, I know that in Delphi Android app I can have only one activity, which is FMXNativeActivity.

 

Question is, is it possible to activate it for specific form? The case here is, I need to have acceleration disabled at application level, so low-end smartphones can run my application, but one of my form uses TWebBrowser, this requires acceleration to render more demanding pages.

 

Many thanks for any clues!

Share this post


Link to post

I'm not sure you can really disable hardware acceleration as FMX for Android relies on the GPU canvas which is OpenGL hardware accelerated.

 

But seriously though, OpenGL hardware acceleration has been built into smartphones for well over 5 years, so even old phones have it.

 

Not to mention you would have to use Delphi v10.2 or older to even support versions of Android older than v5 and you won't be able to upload these apps into the app store because they don't support the Android SDK google is requiring to upload new apps to the store (not to mention the 64bit issue).

Edited by Yaron

Share this post


Link to post

Well, at least I can disable it in Android manifest and see results in the app, so I guess it is possible and affects FMX.

 

My issues came from TMapView, on Android 9 it crashes the app, even if I followed Dave's post: https://www.delphiworlds.com/2019/02/a-fix-for-using-tmapview-on-android-9-devices/, it still won't help. On many Adnroid 9 devices with hardware acceleration enabled and TMapView with Delphi 10.3.2, it will crash the application with error message regarding eglMakeCurrent (GLSurfaceView issue?). After lots of digging, disabling acceleration prevents from crashing, and TMapView works almost OK, almost because once showed, cannot be closed and user is forced to exit the application. So I decided to ditch TMapView completely and with hardware acceleration enabled it seems to be fine. And now I have replaced TMapView with TWebBrowser showing MapBox 🙂 And it works even better, it requires some more effort on the back-end side, but it was worth it. Never the less, I was thinking about abilities to having GPU on/off for the views, much like native Android app would have.

 

No easy way out, but that is the cost of cross-platform I guess 🙂 

Share this post


Link to post

You should also be aware that disabling hardware acceleration can harshly impact battery usage for your app.

Share this post


Link to post
On 10/28/2019 at 12:01 AM, TomDevOps said:

 I need to have acceleration disabled at application level, so low-end smartphones can run my application,

Can you please point out what low-end means, for what model are you targeting ?

Are there any reasonable phones w/o hardware acceleration (beside maybe chinese lowest cost items) ?

Edited by Rollo62

Share this post


Link to post
On 10/29/2019 at 7:06 AM, Rollo62 said:

Can you please point out what low-end means, for what model are you targeting ?

Are there any reasonable phones w/o hardware acceleration (beside maybe chinese lowest cost items) ?

So far I got those that often crashes at start due to TMapView component (all Android 9):

 

Galaxy A40 (a40)    
Galaxy A50 (a50)    
Galaxy S9 (starlte)    
Galaxy S8 (dreamlte)    
Galaxy A7 (2018) (a7y18lte)    
LG G7 ThinQ (judyln)    
Galaxy S10e (beyond0)    
P10 (HWVTR)    
Redmi Note 7 (lavender)    
MI 8 (dipper)    
Galaxy S8+ (dream2lte)    
Galaxy Note8 (greatlte)    
Honor 10 (HWCOL)    
POCO F1 (beryllium)    
MI 9 (cepheus)    
Galaxy S10+ (beyond2)    
Galaxy A70 (a70q)    
Mate 20 Pro (HWLYA)    
nova 3 (HWPAR)    
Redmi Note 5 Pro (whyred)    
 

If I have TMapView with hardware acceleration enabed, it crashes with eglCurrentContext error. If I disable hardware acceleration, they do not crash, but map once showed, cannot be hide. The exception is as follows:

 

Quote
java.lang.NoClassDefFoundError:
 
at ce.b (com.google.android.gms.dynamite_mapsdynamite@19420081@19.4.20 (100400-271418971):3)
 
at cb.a (com.google.android.gms.dynamite_mapsdynamite@19420081@19.4.20 (100400-271418971):3)
 
at cd.a (com.google.android.gms.dynamite_mapsdynamite@19420081@19.4.20 (100400-271418971):14)
 
at com.google.maps.api.android.lib6.drd.aj.a (com.google.android.gms.dynamite_mapsdynamite@19420081@19.4.20 (100400-271418971):4)
 
at bf.a (com.google.android.gms.dynamite_mapsdynamite@19420081@19.4.20 (100400-271418971):22)
 
at bf.run (com.google.android.gms.dynamite_mapsdynamite@19420081@19.4.20 (100400-271418971):8)
Caused by: java.lang.ClassNotFoundException:
 
at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:134)
 
at java.lang.ClassLoader.loadClass (ClassLoader.java:379)
 
at ad.loadClass (com.google.android.gms.dynamite_dynamiteloader@19420081@19.4.20 (100400-271418971):4)
 
at java.lang.ClassLoader.loadClass (ClassLoader.java:312)

 

 I have solved the issue by removing the TMapView component completly, no Google services at all. I have replaced with TWebBrowser and Open Street Map (hardware acc. is on) - it does the job for me 🙂

 

 

Edited by TomDevOps

Share this post


Link to post

Good that you solved your issue with OSM.

 

However, its strange that your apps crash on most of these phones.
I have not all of your phones in the list, but maybe 40-50%, OK the MapView is not the main purpose in my apps. so its probably not stretched to the max.

I would expect anything like  > Galaxy 7 should make not such issues with GPU at all, when following the advices above.
Somethimes the issues may come from a total different side, are you sure you had a valid GoogleMaps Token and defined correct in the dashboard ?

Have you tried a new, blank app, with MapView only ?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×