[osg-users] Android: Survive Context Loss without complete reinitialization

Martin Siggel martinsiggel+osg at gmail.com
Tue Jul 23 04:15:32 PDT 2019

Dear Robert,

I am now on master. The problems still exist.

> Those shaders are related to the shader pipeline that is only part of master, they don't exist in 3.6.

You are right. Lets forget the inbuilt shaders. The problems occur
also with my own shaders. The only place I use the inbuilt ones are
for text nodes. Those also existed in rc3.

> Or are you using osgUtil::ShaderGen?


> What hardware/software Android platform are you testing with?

I am testing it in the android emulator that comes with the Android
SDK. Additionally I also have a One Plus 3 around, which show the same

Is there any way I can help you setting up an Android Dev environment?
I am thinking of a virtual machine that I could create for testing. Or
step by step instructions, how to build OSG and the example.

But maybe lets not focus too much on android. It seems, that similar
issues also occurred with qt, when a gl context was recreated. My
question is, how to properly notify to OSG, that all shaders +
uniforms are invalid such that it recompiles them. Actually, OSG
already recompiles the shader after creating a new embedded window and
therefore increasing the context id. Maybe the old shader objects are
not disposed properly and are still attached to the stateset (just

Unfortunately, I don't know OSG much that I can find out, what is
actually going wrong.


Am Di., 23. Juli 2019 um 11:03 Uhr schrieb Robert Osfield
<robert.osfield at gmail.com>:
> Hi Martin,
> On Mon, 22 Jul 2019 at 19:33, Martin Siggel <martinsiggel+osg at gmail.com> wrote:
> > I am using OSG 3.6.4-rc3.
> That's from back in January so it would be worth updating to 3.6.4-rc8.
> I've done a diff between rc3 and rc8 and overall there are quite a few fixes, I couldn't see a change that would affect things for you with osgText.
> > The only built-in shaders I am using right now are the osgText shaders:
> https://github.com/openscenegraph/OpenSceneGraph/tree/master/src/osgText/shaders
> These are automatically bound, when no other shaders are added to a text node.
> > When I don't add shaders to a geometry node, other built-in shaders seem to get active as well. I guess these are the ones from https://github.com/openscenegraph/OpenSceneGraph/tree/master/src/osg/shaders.
> Those shaders are related to the shader pipeline that is only part of master, they don't exist in 3.6.  If you are aren't creating your own shaders do they come with your data?  Or are you using osgUtil::ShaderGen?
> > When I e.g. use osgText, the text will appear after starting the application. When I go to the android main screen and then go back to the app, the text nodes will become black rectangles. Somehow, osg seems to reference still the "old" objects from the context before.
> > Still, from the log I can verify, that shaders are compiled again after resuming to the app.
> What hardware/software Android platform are you testing with?
> > I could provide a "minimal" example if anyone is interested.
> I don't personally have a Android dev environment setup, so I can't test.  I was hoping that other Android users would chip in here, unfortunately the forum has been a bit unreliable of late so perhaps this is contributing.
> Cheers,
> Robert.
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

More information about the osg-users mailing list