Slow drawing on Android

A test application which draws random colored backgrounds in four square sub-components (which split the screen into 4 equal regions): runs 10X slower on Android than on macOS or Linux. The CPU speed difference between my test phone and my desktops is only about 1.5 to 2x; I wouldn’t expect a 10x slowdown.

I’ve tried to get OpenGL rendering to work, unsuccessfully as mentioned here.

If I change the colors to have an alpha component, the drawing is almost twice as slow. I assume that’s because of using the CPU to do software blending, but my desktops are doing the same thing (presumably).

As pointed out on the other thread, I’m using JUCE 4, since that’s what I have a commercial license for.

Practical suggestions most welcome…

None of the Android dev team care to comment?

We’ve made it clear for a long time that the software renderer is going to perform really badly on Android! The pixel/CPU ratio is really stacked against it, and we recommend only using the GL renderer on Android. We may even deprecate the software renderer on that platform to make this more clear to people.

Everyone we know is using the GL renderer quite happily on Android so maybe you just need to figure out what you’re doing wrong. The other thread you linked to doesn’t seem to be about GL on Android at all - it’s about OSX, isn’t it?

I cannot get the GL renderer to work on any platform, Android included. So the other thread includes this one.

As far as I can see, there is no sample code which shows a basic Android application using the GL renderer without it being an actual GL application. That is to say, a “normal” application which uses the GL renderer to do the regular drawing.

I would be happy to be mistaken about that, but I cannot find it in either the JUCE4 or JUCE5 samples.

The docs for OpenGLContext state what should be the simple case:

" To render some OpenGL, you should create an instance of an OpenGLContext, and call attachTo() to make it use a component as its render target.

To provide threaded rendering, you can supply an OpenGLRenderer object that will be used to render each frame."

So I create a context and call attachTo() on the component, and JUCE doesn’t render anything on that component. That is my problem, and it’s the same across all OSes. I am creating the context in the same JUCE thread where I create the component, I’m not trying anything fancy.

What do you mean by an “actual GL application”? The DemoRunner application uses the GL renderer by default on Android to do all of the drawing - the code is here and you can see that in updateRenderingEngine() it just calls attachTo() to attach the GL context to the top-level component. I’m not sure about the issues that you’re having with the GL renderer, but I’d recommend trying it out with the latest JUCE version as there have been a number of fixes since JUCE 4…

2 Likes