Error #3691: Resource limit for this resource type exceeded
This topic is discussed in a few threads, within the Starling and Away3D forums. I initially looked in the Adobe forums but did not find anything, surprisingly, so I thought I'd post my work around.
I recently ran into "Error #3691: Resource limit for this resource type exceeded", while disposing and creating textures in Stage3D.
I have an app where the user gets to pick one of 4 render quality levels. Picking any one of these settings calls my own setRenderQualityLevel(), which does the following:
- Dispose all textures used in the game ( incl. an intermediary frame buffer )
- Resize my source BitmapDatas to the desired resolution based on the render quality level.
- Upload the resized bitmapDatas to the GPU via Context3D.createTexture().
- Do a single call to my render() function to see the change
Now, I noticed that if I kept switching render quality levels while the game was running ( basically while an enter-frame handler was calling my render() function ) then error #3691 would not happen.
However, if I paused the game ( unhooking the enter-frame handler, and thus no render() calls every frame ), then I would eventually get the error when toggling between render quality levels.
The fix: adding a second call to render() within setRenderQualityLevel() got rid of the error, when the game was paused!
My take: apparently, calling dispose() on a texture is not sufficient to get rid of it right there and then: rendering a couple frames is also required ( which means two calls to Context3D.present() ).... weird.
