Compositor2 startup issues on android

Discussion area about developing with Ogre2 branches (2.1, 2.2 and beyond)
Post Reply
renando_stimpy
Gnoblar
Posts: 4
Joined: Sun Sep 13, 2015 9:15 pm

Compositor2 startup issues on android

Post by renando_stimpy »

Hoping someone has some insight into this error cause it's driving me crazy,

Trying to port a cross-platform ( as yet unreleased ) game from 1.9 to 2.0, everything in the game seems to be working across all the platforms except android at this point.

It's tripping on an assert

Code: Select all

Ogre::CompositeNodeDef "mTargetPasses.size() < mTargetPasses.capacity() && "setNumTargetPass called improperly!"" failed on startup.
The assert is being thrown by Ogre::Root::oneTimePostWindowInit in the CompositorManager2 constructor

renderSystem is not NULL and the logs show it's started up fine

Code: Select all

I/OGRE    ( 5330): **************************************
I/OGRE    ( 5330): *** OpenGL ES 2.x Renderer Started ***
I/OGRE    ( 5330): **************************************
I/OGRE    ( 5330): GLSL ES support detected
I/OGRE    ( 5330): Registering ResourceManager for type GpuProgram
I/OGRE    ( 5330): GL ES 2: Using FBOs for rendering to textures
I/OGRE    ( 5330): FBO PF_A8 depth/stencil support: D0S0 D0S1 D0S4 D0S8 D16S0 D16S1 D16S4 D16S8 D24S0 D24S1 D24S4 D24S8 D32S0 D32S1 D32S4 D32S8 Packed-D24S8
I/OGRE    ( 5330): FBO PF_R5G6B5 depth/stencil support: D0S0 D0S1 D0S4 D0S8 D16S0 D16S1 D16S4 D16S8 D24S0 D24S1 D24S4 D24S8 D32S0 D32S1 D32S4 D32S8 Packed-D24S8
I/OGRE    ( 5330): FBO PF_B5G6R5 depth/stencil support: D0S0 D0S1 D0S4 D0S8 D16S0 D16S1 D16S4 D16S8 D24S0 D24S1 D24S4 D24S8 D32S0 D32S1 D32S4 D32S8 Packed-D24S8
I/OGRE    ( 5330): FBO PF_A4R4G4B4 depth/stencil support: D0S0 D0S1 D0S4 D0S8 D16S0 D16S1 D16S4 D16S8 D24S0 D24S1 D24S4 D24S8 D32S0 D32S1 D32S4 D32S8 Packed-D24S8
I/OGRE    ( 5330): FBO PF_A1R5G5B5 depth/stencil support: D0S0 D0S1 D0S4 D0S8 D16S0 D16S1 D16S4 D16S8 D24S0 D24S1 D24S4 D24S8 D32S0 D32S1 D32S4 D32S8 Packed-D24S8
I/OGRE    ( 5330): FBO PF_R8G8B8 depth/stencil support: D0S0 D0S1 D0S4 D0S8 D16S0 D16S1 D16S4 D16S8 D24S0 D24S1 D24S4 D24S8 D32S0 D32S1 D32S4 D32S8 Packed-D24S8
I/OGRE    ( 5330): FBO PF_B8G8R8 depth/stencil support: D0S0 D0S1 D0S4 D0S8 D16S0 D16S1 D16S4 D16S8 D24S0 D24S1 D24S4 D24S8 D32S0 D32S1 D32S4 D32S8 Packed-D24S8
I/OGRE    ( 5330): FBO PF_A8R8G8B8 depth/stencil support: D0S0 D0S1 D0S4 D0S8 D16S0 D16S1 D16S4 D16S8 D24S0 D24S1 D24S4 D24S8 D32S0 D32S1 D32S4 D32S8 Packed-D24S8
D/dalvikvm( 5330): GC_FOR_ALLOC freed 500K, 13% free 4319K/4916K, paused 3ms, total 3ms
I/OGRE    ( 5330): FBO PF_A8B8G8R8 depth/stencil support: D0S0 D0S1 D0S4 D0S8 D16S0 D16S1 D16S4 D16S8 D24S0 D24S1 D24S4 D24S8 D32S0 D32S1 D32S4 D32S8 Packed-D24S8
I/OGRE    ( 5330): FBO PF_B8G8R8A8 depth/stencil support: D0S0 D0S1 D0S4 D0S8 D16S0 D16S1 D16S4 D16S8 D24S0 D24S1 D24S4 D24S8 D32S0 D32S1 D32S4 D32S8 Packed-D24S8
I/OGRE    ( 5330): FBO PF_FLOAT16_RGB depth/stencil support: D0S0 D0S1 D0S4 D0S8 D16S0 D16S1 D16S4 D16S8 D24S0 D24S1 D24S4 D24S8 D32S0 D32S1 D32S4 D32S8 Packed-D24S8
I/OGRE    ( 5330): FBO PF_FLOAT32_RGB depth/stencil support: D0S0 D0S1 D0S4 D0S8 D16S0 D16S1 D16S4 D16S8 D24S0 D24S1 D24S4 D24S8 D32S0 D32S1 D32S4 D32S8 Packed-D24S8
I/OGRE    ( 5330): FBO PF_X8R8G8B8 depth/stencil support: D0S0 D0S1 D0S4 D0S8 D16S0 D16S1 D16S4 D16S8 D24S0 D24S1 D24S4 D24S8 D32S0 D32S1 D32S4 D32S8 Packed-D24S8
I/OGRE    ( 5330): FBO PF_SHORT_RGBA depth/stencil support: D0S0 D0S1 D0S4 D0S8 D16S0 D16S1 D16S4 D16S8 D24S0 D24S1 D24S4 D24S8 D32S0 D32S1 D32S4 D32S8 Packed-D24S8
I/OGRE    ( 5330): [GLES2] : Valid FBO targets PF_A8 PF_R5G6B5 PF_B5G6R5 PF_A4R4G4B4 PF_A1R5G5B5 PF_R8G8B8 PF_B8G8R8 PF_A8R8G8B8 PF_A8B8G8R8 PF_B8G8R8A8 PF_FLOAT16_RGB PF_FLOAT32_RGB PF_X8R8G8B8 PF_SHORT_RGBA
I/OGRE    ( 5330): RenderSystem capabilities
I/OGRE    ( 5330): -------------------------
I/OGRE    ( 5330): RenderSystem Name: OpenGL ES 2.x Rendering Subsystem
I/OGRE    ( 5330): GPU Vendor: unknown
I/OGRE    ( 5330): Device Name: Android Emulator OpenGL ES Translator (Intel(R) HD Graphics 4600)
I/OGRE    ( 5330): Driver Version: 0.0.0.0
I/OGRE    ( 5330):  * Fixed function pipeline: no
I/OGRE    ( 5330):  * Hardware generation of mipmaps: yes
I/OGRE    ( 5330):  * Texture blending: yes
I/OGRE    ( 5330):  * Anisotropic texture filtering: no
I/OGRE    ( 5330):  * Dot product texture operation: yes
I/OGRE    ( 5330):  * Cube mapping: yes
I/OGRE    ( 5330):  * Hardware stencil buffer: no
I/OGRE    ( 5330):  * Hardware vertex / index buffers: yes
I/OGRE    ( 5330):  * 32-bit index buffers: yes
I/OGRE    ( 5330):  * Vertex programs: yes
I/OGRE    ( 5330):  * Number of floating-point constants for vertex programs: 1024
I/OGRE    ( 5330):  * Number of integer constants for vertex programs: 1024
I/OGRE    ( 5330):  * Number of boolean constants for vertex programs: 1024
I/OGRE    ( 5330):  * Fragment programs: yes
I/OGRE    ( 5330):  * Number of floating-point constants for fragment programs: 1024
I/OGRE    ( 5330):  * Number of integer constants for fragment programs: 1024
I/OGRE    ( 5330):  * Number of boolean constants for fragment programs: 1024
I/OGRE    ( 5330):  * Geometry programs: no
I/OGRE    ( 5330):  * Number of floating-point constants for geometry programs: 0
I/OGRE    ( 5330):  * Number of integer constants for geometry programs: 0
I/OGRE    ( 5330):  * Number of boolean constants for geometry programs: 0
I/OGRE    ( 5330):  * Tessellation Hull programs: no
I/OGRE    ( 5330):  * Number of floating-point constants for tessellation hull programs: 0
I/OGRE    ( 5330):  * Number of integer constants for tessellation hull programs: 0
I/OGRE    ( 5330):  * Number of boolean constants for tessellation hull programs: 0
I/OGRE    ( 5330):  * Tessellation Domain programs: no
I/OGRE    ( 5330):  * Number of floating-point constants for tessellation domain programs: 0
I/OGRE    ( 5330):  * Number of integer constants for tessellation domain programs: 0
I/OGRE    ( 5330):  * Number of boolean constants for tessellation domain programs: 0
I/OGRE    ( 5330):  * Compute programs: no
I/OGRE    ( 5330):  * Number of floating-point constants for compute programs: 0
I/OGRE    ( 5330):  * Number of integer constants for compute programs: 0
I/OGRE    ( 5330):  * Number of boolean constants for compute programs: 0
I/OGRE    ( 5330):  * Supported Shader Profiles: glsles
I/OGRE    ( 5330):  * Texture Compression: yes
I/OGRE    ( 5330):    - DXT: no
I/OGRE    ( 5330):    - VTC: no
I/OGRE    ( 5330):    - PVRTC: no
I/OGRE    ( 5330):    - ATC: no
I/OGRE    ( 5330):    - ETC1: yes
I/OGRE    ( 5330):    - ETC2: no
I/OGRE    ( 5330):    - BC4/BC5: no
I/OGRE    ( 5330):    - BC6H/BC7: no
I/OGRE    ( 5330):  * Scissor Rectangle: yes
I/OGRE    ( 5330):  * Hardware Occlusion Query: no
I/OGRE    ( 5330):  * User clip planes: no
I/OGRE    ( 5330):  * VET_UBYTE4 vertex element type: yes
I/OGRE    ( 5330):  * Infinite far plane projection: yes
I/OGRE    ( 5330):  * Hardware render-to-texture: yes
I/OGRE    ( 5330):  * Floating point textures: yes
I/OGRE    ( 5330):  * Non-power-of-two textures: no (limited)
I/OGRE    ( 5330):  * 1d textures: yes
I/OGRE    ( 5330):  * Volume textures: no
I/OGRE    ( 5330):  * Multiple Render Targets: 1
I/OGRE    ( 5330):    - With different bit depths: no
I/OGRE    ( 5330):  * Point Sprites: yes
I/OGRE    ( 5330):  * Extended point parameters: yes
I/OGRE    ( 5330):  * Max Point Size: 0
I/OGRE    ( 5330):  * Vertex texture fetch: no
I/OGRE    ( 5330):  * Number of world matrices: 0
I/OGRE    ( 5330):  * Number of texture units: 16
I/OGRE    ( 5330):  * Stencil buffer depth: 0
I/OGRE    ( 5330):  * Number of vertex blend matrices: 0
I/OGRE    ( 5330):  * Render to Vertex Buffer : no
I/OGRE    ( 5330):  * Hardware Atomic Counters: no
I/OGRE    ( 5330):  * GL 1.5 without VBO workaround: no
I/OGRE    ( 5330):  * Frame Buffer objects: yes
I/OGRE    ( 5330):  * Frame Buffer objects (ARB extension): no
I/OGRE    ( 5330):  * Frame Buffer objects (ATI extension): no
I/OGRE    ( 5330):  * PBuffer support: no
I/OGRE    ( 5330):  * GL 1.5 without HW-occlusion workaround: no
I/OGRE    ( 5330):  * Vertex Array Objects: no
I/OGRE    ( 5330):  * Separate shader objects: no
Then the work queue starts up

Code: Select all

I/OGRE    ( 5330): DefaultWorkQueue('Root') initialising on thread b77a9040.
I/OGRE    ( 5330): DefaultWorkQueue('Root')::WorkerFunc - thread b91dc020 starting.
I/OGRE    ( 5330): DefaultWorkQueue('Root')::WorkerFunc - thread b91dc300 starting.
I/OGRE    ( 5330): DefaultWorkQueue('Root')::WorkerFunc - thread b91e6740 starting.
I/OGRE    ( 5330): DefaultWorkQueue('Root')::WorkerFunc - thread b91e6988 starting.
F/libc    ( 5330): /home/cerebralfix/beachhead_androiddeps/ogre/OgreMain/src/Compositor/OgreCompositorNodeDef.cpp:46: Ogre::CompositorTargetDef* Ogre::CompositorNodeDef::addTargetPass(const String&, Ogre::uint32): assertion "mTargetPasses.size() < mTargetPasses.capacity() && "setNumTargetPass called improperly!"" failed
The weird thing is when I debug the following:

Code: Select all

nodeDef->setNumTargetPass( 1 );
At this point mNumTargetPasses.capacity() logs out as 1, size is 0 which seems correct

But on the very next line:

Code: Select all

CompositorTargetDef *targetDef = nodeDef->addTargetPass( "WindowRT" );
It asserts that nodeDefs::mNumTargetPass capacity is 0 and size is 0,

Is it even possible that vector could lose it's capacity between these 2 lines ? - If so any ideas ?

Any help much appreciated, if more info is needed just ask, happy to provide.

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4212
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 802
Contact:

Re: Compositor2 startup issues on android

Post by dark_sylinc »

Good news all that code that is failing is not needed. It's just some left over that I forgot to cleanup (also a good example to show people how to do it manually... but ok it shouldn't be there executing).

Bad news, like you said that shouldn't be happening at all. Like you said capacity should stay in 1 between those lines.
I would suggest printing the pointer address of &this->mTargetPasses and 'this' to see if it had changed.

Otherwise the way to be fully sure what's going on is to use data breakpoints. For example in my Linux std lib implementation capacity is defined as:

Code: Select all

size_type
      capacity() const _GLIBCXX_NOEXCEPT
      { return size_type(this->_M_impl._M_end_of_storage
			 - this->_M_impl._M_start); }
Which means I would have to add two data breakpoints on the addresses of mTargetPasses._M_impl._M_end_of_storage and mTargetPasses._M_impl._M_start

I wouldn't rule out a flaw in the std lib implementation of Android. There are certainly many I've encountered in the past. Also debugging in Android is certainly painful.

Edit: The original code calls nodeDef->setNumTargetPass( 1 ); outside the scope, then calls nodeDef->addTargetPass( "WindowRT" ); inside a scope. Try putting the nodeDef->setNumTargetPass( 1 ); inside the same scope.
If GCC is inlining the setNumTargetPass code and having a bug along the way (using a temporary vector instead of mTargetPasses), it could happen I guess.
Edit 2: If this is too much for you to handle, you can remove the offending code. However I suspect whatever weird thing is going on here could come to bite you later on.

renando_stimpy
Gnoblar
Posts: 4
Joined: Sun Sep 13, 2015 9:15 pm

Re: Compositor2 startup issues on android

Post by renando_stimpy »

Thanks for the pointers, It looks like it's not an Ogre issue just android being android.

I've removed the offending code from the constructor of CompositorManager2 which had a happy side effect of moving the error out of Ogre and into our codebase which makes it easier to step through, I'm assuming when you say 'redundant code' you mean in that particular constructor ?

We use the following code to create compositor workspaces that have transparent backgrounds ( 1 workspace per 'screen' layer - as we have the idea of render layers with 1 sceneManager and a 2d render pass hooked into that sceneManagers render queue, allowing for layered 3d and 2D.

Code: Select all

Ogre::IdString OgreScene::createCompositorWorkspace(const std::string& _id, bool _isTransparent)
{
	Ogre::IdString wsName = _id;
	Ogre::CompositorManager2* compMan = Ogre::Root::getSingletonPtr()->getCompositorManager2();
	
	// don't recreate it
	if (compMan->hasWorkspaceDefinition(wsName)) { return wsName; }

	Ogre::CompositorNodeDef *nodeDef = compMan->addNodeDefinition("AutoGen " + (wsName + Ogre::IdString("/Node")).getReleaseText());

	// input texture
	nodeDef->addTextureSourceName("WindowRT", 0, Ogre::TextureDefinitionBase::TEXTURE_INPUT);

	nodeDef->setNumTargetPass(1);
	Ogre::CompositorTargetDef *targetDef = nodeDef->addTargetPass("WindowRT");
	targetDef->setNumPasses(2);
	Ogre::CompositorPassClearDef *passClear = static_cast<Ogre::CompositorPassClearDef*>(targetDef->addPass(Ogre::PASS_CLEAR));
	passClear->mColourValue = Ogre::ColourValue::ZERO;
	if (_isTransparent)
	{
		passClear->mClearBufferFlags = Ogre::FBT_DEPTH;
	}
	Ogre::CompositorPassSceneDef *passScene = static_cast<Ogre::CompositorPassSceneDef*>(targetDef->addPass(Ogre::PASS_SCENE));
	passScene->mShadowNode = Ogre::IdString();
	passScene->mVpLeft = 0.0f;
	passScene->mVpTop = 1.0 - m_contentScaleFactor;
	passScene->mVpWidth = m_contentScaleFactor;
	passScene->mVpHeight = m_contentScaleFactor;

	Ogre::CompositorWorkspaceDef *workDef = compMan->addWorkspaceDefinition(wsName);
	workDef->connectOutput(nodeDef->getName(), 0);
	return wsName;
}
It's basically a rehash of that constructor code, If all of that code is redundant then I'm missing something.

I did what you suggested re. debugging, turns out the reserve call has issues as _M_impl._M_start and _M_impl._M_end_of_storage are both 0x0 at the end of it.

So looks like it's a strange stdlib issue at this point - or potentially we have conflicting version of libstdc++ somewhere, I'll try a different toolchain version and maybe a different ndk,

Which NDK version do you test with personally for android ? - Since this project has been going for a year or so now we are still using android-ndk-r9d.

Will post the solution if one is found.

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4212
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 802
Contact:

Re: Compositor2 startup issues on android

Post by dark_sylinc »

renando_stimpy wrote:I'm assuming when you say 'redundant code' you mean in that particular constructor ?
I don't see I said "redundant" in my code. Perhaps you meant when I said 'offending code' (as in.. the code that was causing the bug).
It's basically a rehash of that constructor code, If all of that code is redundant then I'm missing something.
Nope, it's fine ;)
Which NDK version do you test with personally for android ? - Since this project has been going for a year or so now we are still using android-ndk-r9d.
It's been a long time I've done Android programming, and last thing I tried was android-ndk-r9d as well. But IIRC there were multiple implementations of the stdlib to choose from, and I don't remember which one I used.
I've always used static version of Ogre libs for Android.

Btw IIRC the SampleBrowser compiles for Android in 2.0. See if it works there.

renando_stimpy
Gnoblar
Posts: 4
Joined: Sun Sep 13, 2015 9:15 pm

Re: Compositor2 startup issues on android

Post by renando_stimpy »

Sorry I was reading into 'not needed' and 'left over' ~ my bad :)

In the end the problem was on our end and was rather simple to fix - Our apps libraries were compiled with the 4.8 version of the various toolchains, CMake decided to default to 4.6, I recompiled ogre with the correct toolchain version and the vector now resizes correctly.

Thanks for your help and the excellent work on Ogre 2.0 - Performance is so much better.

Post Reply