Getting EXC_BAD_ACCESS with Cocos2d & Box2d while attempting to use DebugDraw - cocos2d-iphone

this thing is making me crazy!
I'm experimenting with Cocos2d (0.99.5) and Box2D, and I have successfully created a scene with a layer and two bodies (actually a couple of bouncing balls). Now I would like to enable the DebugDrawing so I can see exactly what is happening. Consider that everything works with DebugDrawing disabled.
Talking about the code, in my init method I have this:
m_debugDraw = new GLESDebugDraw(PTM_RATIO);
uint32 flags;
flags = 0;
flags += 1 * b2DebugDraw::e_shapeBit;
flags += 1 * b2DebugDraw::e_jointBit;
flags += 1 * b2DebugDraw::e_aabbBit;
flags += 1 * b2DebugDraw::e_pairBit;
flags += 1 * b2DebugDraw::e_centerOfMassBit;
m_debugDraw->SetFlags(flags);
_world->SetDebugDraw(m_debugDraw);
My draw method is as follows:
-(void)draw {
[super draw];
glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
_world->DrawDebugData(); // <------ here comes the problem
glEnable(GL_TEXTURE_2D);
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
}
The problem is that when the program reaches the line
_world->DrawDebugData();
an EXC_BAD_ACCESS exception in thrown. The debugger shows the error here:
void b2World::DrawDebugData()
{
if (m_debugDraw == NULL)
{
return;
}
uint32 flags = m_debugDraw->GetFlags(); // <----- this is the row pointed by Xcode
if (flags & b2DebugDraw::e_shapeBit)
{
[...]
The error shown on the main window is: "Thread 1: Program received signal: 'EXC_BAD_ACCESS'". This is the output I get:
GNU gdb 6.3.50-20050815 (Apple version gdb-1515) (Sat Jan 8 00:31:48 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=x86_64-apple-darwin --target=arm-apple-darwin".tty /dev/ttys000
target remote-mobile /tmp/.XcodeGDBRemote-191-40
Switching to remote-macosx protocol
mem 0x1000 0x3fffffff cache
mem 0x40000000 0xffffffff none
mem 0x00000000 0x0fff none
[Switching to thread 11779]
[Switching to thread 11779]
sharedlibrary apply-load-rules all
2011-03-03 22:10:36.477 MyApp[2738:707] cocos2d: cocos2d v0.99.5
2011-03-03 22:10:36.529 MyApp[2738:707] cocos2d: Using Director Type:CCDirectorDisplayLink
2011-03-03 22:10:36.936 MyApp[2738:707] cocos2d: OS version: 4.3 (0x04030000)
2011-03-03 22:10:36.943 MyApp[2738:707] cocos2d: GL_VENDOR: Imagination Technologies
2011-03-03 22:10:36.949 MyApp[2738:707] cocos2d: GL_RENDERER: PowerVR SGX 535
2011-03-03 22:10:36.956 MyApp[2738:707] cocos2d: GL_VERSION: OpenGL ES-CM 1.1 IMGSGX535-58.1
2011-03-03 22:10:36.966 MyApp[2738:707] cocos2d: GL_MAX_TEXTURE_SIZE: 2048
2011-03-03 22:10:36.973 MyApp[2738:707] cocos2d: GL_MAX_MODELVIEW_STACK_DEPTH: 16
2011-03-03 22:10:36.979 MyApp[2738:707] cocos2d: GL_MAX_SAMPLES: 4
2011-03-03 22:10:37.020 MyApp[2738:707] cocos2d: GL supports PVRTC: YES
2011-03-03 22:10:37.026 MyApp[2738:707] cocos2d: GL supports BGRA8888 textures: YES
2011-03-03 22:10:37.033 MyApp[2738:707] cocos2d: GL supports NPOT textures: YES
2011-03-03 22:10:37.039 MyApp[2738:707] cocos2d: GL supports discard_framebuffer: YES
2011-03-03 22:10:37.060 MyApp[2738:707] cocos2d: compiled with NPOT support: NO
2011-03-03 22:10:37.066 MyApp[2738:707] cocos2d: compiled with VBO support in TextureAtlas : YES
2011-03-03 22:10:37.072 MyApp[2738:707] cocos2d: compiled with Affine Matrix transformation in CCNode : YES
2011-03-03 22:10:37.078 MyApp[2738:707] cocos2d: compiled with Profiling Support: NO
2011-03-03 22:10:44.375 MyApp[2738:707] cocos2d: Frame interval: 1
2011-03-03 22:10:44.420 MyApp[2738:707] cocos2d: surface size: 320x480
2011-03-03 22:10:44.654 MyApp[2738:707] Received memory warning. Level=1
2011-03-03 22:10:44.696 MyApp[2738:707] cocos2d: deallocing
"MenuBackGround.png",
"Star.png",
"fps_images.png"
)>
Current language: auto; currently c++
(gdb)
I have tried googling and I found out a lot of things about this error, still I can't solve it. It happens both on the simulator and on the iPhone. Someone on another discussion (sorry, lost the link) pointed out that it may be related to the compiler or the optimization, thus I tried different combinations switching from LLVM to GCC to LLVM-GCC and setting the optimization at different levels with no success.
Can someone point me in the right direction? Let me know if more information is needed.
Thanks you all,
Daniele Salatti

The only difference to the Cocos2D Box2D template is that you are calling SetDebugDraw after assigning the flags. It shouldn't make any difference but you might want to try it exactly like the Box2D template project does:
world = new b2World(gravity, doSleep);
world->SetContinuousPhysics(true);
// Debug Draw functions
m_debugDraw = new GLESDebugDraw( PTM_RATIO );
world->SetDebugDraw(m_debugDraw);
uint32 flags = 0;
flags += b2DebugDraw::e_shapeBit;
m_debugDraw->SetFlags(flags);
Update: I found another difference. In your draw method, you're calling [super draw]. The Box2D template project doesn't do that. Again, it should not make any difference but you never know. If it still crashes I recommend to compare your project with the Box2D template to find any other (possibly subtle) differences. In addition to the usual recommendations to exclude all compiler hiccups: cleaning all targets, deleting build folder, restarting Xcode (and entire machine), deleting the App from Simulator/Device (and rebooting device).
PS: I see you're using underscore prefixes as in: _world. Apple recommends not to do that since underscore prefixes are reserved for their own internal use, as well as some C style functions. In ObjC, if you must name member variables according to some scheme, prefer to use underscore suffixes as in world_->SetDebugDraw()
Personally I try to avoid these world, world or m_world naming schemes altogether, there's really no point in that other than tradition and conflicting function parameter names. Where necessary, I rather change the function parameter names to have a suffixed underscore.

Take a look at your world and debugDraw variables with debugger. Looks like one of them is corrupted

Related

OpenGL version 2.1 is not supported by graphics driver and maybe need to update

I am using mayavi to do some visualization task on my remote server with GPUs.When my code run mlab.show(),the following error occurred
qt.glx: qglx_findConfig: Failed to finding matching FBConfig (8 8 8 0)
...
qt.glx: qglx_findConfig: Failed to finding matching FBConfig (1 1 1 0)
ERROR: In /work/standalone-x64-build/VTK-source/Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx, line 797
vtkXOpenGLRenderWindow (0x559c336fd4e0): GL version 2.1 with the gpu_shader4 extension is not supported by your graphics driver but is required for the new OpenGL rendering backend. Please update your OpenGL driver. If you are using Mesa please make sure you have version 10.6.5 or later and make sure your driver in Mesa supports OpenGL 3.2.
I am using Ubuntu16.04 and here is some info about my remote server.
(base) zz#SYS-4028GR-TR:~$ glxinfo | grep OpenGL
OpenGL vendor string: Mesa project: www.mesa3d.org
OpenGL renderer string: Mesa GLX Indirect
OpenGL version string: 1.3 Mesa 4.0.4
OpenGL extensions:
(base) zz#SYS-4028GR-TR:~$ glxinfo | grep render
direct rendering: No (If you want to find out why, try setting LIBGL_DEBUG=verbose)
GLX_MESA_multithread_makecurrent, GLX_MESA_query_renderer,
OpenGL renderer string: Mesa GLX Indirect
Does anyone have some ideas about this situation?I try to found some ways to update Mesa in Ubuntu but failed.If there is any way to deal with this kind of problem, it would be very helpful.
I am using mayavi to do some visualization task on my remote server with GPUs.
"Remote Server", that's your problem right there. If you log in via SSH forwarding the X11 connection, all OpenGL commands are serialized as GLX commands and tunneled through the X11 connection over the network to your computer to be executed on your local graphics system.
If you have a GPU on the remote system, your best option these days is to use Xpra, configuring so that it launches its backing X server on the GPU and not with a virtual framebuffer device.
What this comes down to is to install the regular Xorg server. Modify /etc/X11/Xwrapper to allow start by a regular user. You can then start the X server with Xpra being the first client with the command line
startx /usr/bin/Xpra start :100 --use-display --daemon=no -- :100
If you don't want to fix your display, then create a executable file /usr/local/bin/xpra_display
#!/bin/sh
exec xpra start $DISPLAY --use-display --daemon=no
which you can then launch with
startx /usr/local/bin/xpra_display
without further arguments

How to enable OpenGL 3.3 using Mesa 10.1 on Ubuntu

I am trying to get an OpenGL-based rendering engine that relies on OpenGL 3.3 and GLSL 3.3 to run on Ubuntu 13.10 using an AMD Radeon 6950. I want to use the open source drivers (radeon), which rely on Mesa for their OpenGL implementation. Ubuntu 13.10 only provides Mesa 9.2 (implementing OpenGL 3.1) "out of the box". It is however possible to install Mesa 10.1 (implementing OpenGL 3.3) from this PPA as explained in this thread:
StackOverflow: OpenGL & GLSL 3.3 on an HD Graphics 4000 under Ubuntu 12.04
I used the exact same steps as explained there:
1.) Add the PPA Repository
$ sudo add-apt-repository ppa:oibaf/graphics-drivers
2.) Update sources
$ sudo apt-get update
3.) Dist-upgrade (rebuilds many packages)
$ sudo apt-get dist-upgrade
4.) Then I rebooted.
Mesa 10.1 was successfully installed. However, glxinfo, while it now reports that Mesa 10.1 is in use, still reports only OpenGL 3.0 (compat profile) and OpenGL 3.1 (core profile):
$ glxinfo | grep OpenGL
OpenGL vendor string: X.Org
OpenGL renderer string: Gallium 0.4 on AMD CAYMAN
OpenGL core profile version string: 3.1 (Core Profile) Mesa 10.1.0-devel (git-7f57408 saucy-oibaf-ppa+curaga)
OpenGL core profile shading language version string: 1.40
OpenGL core profile context flags: (none)
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 10.1.0-devel (git-7f57408 saucy-oibaf-ppa+curaga)
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
Why is that? How can I enable OpenGL 3.3? As can be seen by comparison in the StackOverflow thread that I mentioned, it is possible to have glxinfo report OpenGL 3.3. I am aware that glxinfo may report the wrong version numbers as per the Mesa 10.1 Release Notes, however the rendering engine I'm trying to run fails because of this.
I use the following code to spawn a window:
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, 0);
if(GL_TRUE != glfwOpenWindow(
_windowDimensions.x, _windowDimensions.y,
0, 0, 0, 0, 32, 0, GLFW_WINDOW))
{
THROW("GLFW error: failed to create window.");
}
When I try to run the rendering engine using this setup, the above exception gets thrown as OpenGL 3.3 is not supported. I can set GLFW_OPENGL_VERSION_MINOR to 0 and then the window opens fine, but an exception will be thrown later as GLSL 3.3 shaders are required.
Also note that the rendering engine runs fine when I use the proprietary fglrx drivers (and then glxinfo reports OpenGL version 4.2), so the application itself really is not the problem, but the supported OpenGL is.
So what am I doing wrong? Why doesn't Mesa 10.1 support OpenGL 3.3 for me? My graphics card certainly supports it.
Here's some additional information that may be useful.
$ apt-cache policy libgl1-mesa-glx
libgl1-mesa-glx:
Installed: 10.1~git1402041945.7f5740+curaga~gd~s
Candidate: 10.1~git1402041945.7f5740+curaga~gd~s
Version table:
*** 10.1~git1402041945.7f5740+curaga~gd~s 0
500 http://ppa.launchpad.net/oibaf/graphics-drivers/ubuntu/ saucy/main amd64 Packages
100 /var/lib/dpkg/status
9.2.1-1ubuntu3 0
500 http://archive.ubuntu.com/ubuntu/ saucy/main amd64 Packages
$ lspci -vv
...snip...
01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Cayman PRO [Radeon HD 6950] (prog-if 00 [VGA controller])
Subsystem: Hightech Information System Ltd. Device 2307
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin A routed to IRQ 53
Region 0: Memory at c0000000 (64-bit, prefetchable) [size=256M]
Region 2: Memory at fe620000 (64-bit, non-prefetchable) [size=128K]
Region 4: I/O ports at e000 [size=256]
Expansion ROM at fe600000 [disabled] [size=128K]
Capabilities: <access denied>
Kernel driver in use: radeon
...snip...
$ lsmod | egrep 'radeon|fglrx'
radeon 1402995 3
i2c_algo_bit 13413 1 radeon
ttm 84169 1 radeon
drm_kms_helper 52710 1 radeon
drm 297056 5 ttm,drm_kms_helper,radeon
$ modinfo radeon
filename: /lib/modules/3.11.0-15-generic/kernel/drivers/gpu/drm/radeon/radeon.ko
license: GPL and additional rights
description: ATI Radeon
author: Gareth Hughes, Keith Whitwell, others.
...snip...
firmware: radeon/CAYMAN_smc.bin
firmware: radeon/CAYMAN_rlc.bin
firmware: radeon/CAYMAN_mc.bin
firmware: radeon/CAYMAN_me.bin
firmware: radeon/CAYMAN_pfp.bin
...snip...
srcversion: D174B1E4686391B33437915
alias: pci:v00001002d000099A4sv*sd*bc*sc*i*
alias: pci:v00001002d000099A2sv*sd*bc*sc*i*
...snip...
depends: drm,drm_kms_helper,ttm,i2c-algo-bit
intree: Y
vermagic: 3.11.0-15-generic SMP mod_unload modversions
parm: no_wb:Disable AGP writeback for scratch registers (int)
parm: modeset:Disable/Enable modesetting (int)
parm: dynclks:Disable/Enable dynamic clocks (int)
parm: r4xx_atom:Enable ATOMBIOS modesetting for R4xx (int)
parm: vramlimit:Restrict VRAM for testing (int)
parm: agpmode:AGP Mode (-1 == PCI) (int)
parm: gartsize:Size of PCIE/IGP gart to setup in megabytes (32, 64, etc) (int)
parm: benchmark:Run benchmark (int)
parm: test:Run tests (int)
parm: connector_table:Force connector table (int)
parm: tv:TV enable (0 = disable) (int)
parm: audio:Audio enable (1 = enable) (int)
parm: disp_priority:Display Priority (0 = auto, 1 = normal, 2 = high) (int)
parm: hw_i2c:hw i2c engine enable (0 = disable) (int)
parm: pcie_gen2:PCIE Gen2 mode (-1 = auto, 0 = disable, 1 = enable) (int)
parm: msi:MSI support (1 = enable, 0 = disable, -1 = auto) (int)
parm: lockup_timeout:GPU lockup timeout in ms (defaul 10000 = 10 seconds, 0 = disable) (int)
parm: fastfb:Direct FB access for IGP chips (0 = disable, 1 = enable) (int)
parm: dpm:DPM support (1 = enable, 0 = disable, -1 = auto) (int)
parm: aspm:ASPM support (1 = enable, 0 = disable, -1 = auto) (int)
$ dpkg -S /lib/modules/3.11.0-15-generic/kernel/drivers/gpu/drm/radeon/radeon.ko
linux-image-extra-3.11.0-15-generic: /lib/modules/3.11.0-15-generic/kernel/drivers/gpu/drm/radeon/radeon.ko
$ apt-cache policy linux-image-extra-3.11.0-15-generic
linux-image-extra-3.11.0-15-generic:
Installed: 3.11.0-15.25
Candidate: 3.11.0-15.25
Version table:
*** 3.11.0-15.25 0
500 http://archive.ubuntu.com/ubuntu/ saucy-updates/main amd64 Packages
500 http://archive.ubuntu.com/ubuntu/ saucy-security/main amd64 Packages
100 /var/lib/dpkg/status
What they do not tell you, but indirectly imply ("Some drivers don't support all the features required in OpenGL 3.3."), is that in the last official release of Mesa (10.0), GL 3.3 only works on Intel hardware. This is one of the joys of Intel's close involvement with the Mesa project. If you want reliable GL 3.3 support in any form on AMD hardware, you should use fglrx (the proprietary AMD driver) for the time being.
The development release of Mesa 10.1 may implement GL 3.3 on radeon drivers, but you need to request a 3.3 core profile. You are not doing this currently.
This:
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, 0);
Actually needs to be this:
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
Also, there is no such thing as a GL 3.0 compatibility profile or 3.1 core profile. Profiles were not introduced into OpenGL until 3.2. There is a concept of GL_ARB_compatibility in GL 3.1, but that is not the same thing as a profile; glxinfo is giving misleading information.
I answered the thread OP mentions regarding "OpenGL & GLSL 3.3 on an HD Graphics 4000 under Ubuntu 12.04" but I thought I would give the same answer here too considering info seems so scarce. This works for those using freeglut and glew:
so Ive seen a lot of threads surrounding this and I thought here would be a good place to respond. Im running Ubuntu 15.04 with intel ivybridge. After using the "Intel Graphics installer for linux" application, glxinfo gives the following info regarding openGl:
OpenGL core profile version string: 3.3 (Core Profile) Mesa 10.6.0
OpenGL core profile shading language version string: 3.30
OpenGL version string: 3.0 Mesa 10.6.0
OpenGL shading language version string: 1.30
Now from this you can see that the core profile and glsl version are 3.3,but compatible openGl is only 3.0 thus if you want your code to run with 3.3 you need to specify both an opengl core profile and a glsl core profile. The following steps should work if youre using freeglut and glew:
-the glsl #version should specify that you want the core profile:
#version 330 core
-specify you want opengl 3.3:
glutInitContextVersion (3, 3);
-and finally set glewExperimental to true before glewInit():
glewExperimental = GL_TRUE;
hope this helps some people get started :)

How do I use Shader Model 5.0 compiled shaders in Visual Studio 11?

I am trying to have the .hlsl files in my project pre-/ offline/ buildtime compiled for my C++ DirectX 11 project. Visual Studio compiles the .hlsl files into .cso files. I am now having trouble reading .cso files of SM 5.0 into my program to create a shader.
Here is the code I have to create a Pixel Shader from a precompiled .cso file:
ID3D11VertexShader* PS;
ID3DBlob* PS_Buffer;
D3DReadFileToBlob(L"PixelShader.cso", &PS_Buffer);
d3d11Device->CreatePixelShader(PS_Buffer->GetBufferPointer(), PS_Buffer->GetBufferSize(), NULL, &PS);
d3d11DevCon->PSSetShader(PS, 0, 0);
The pixel shader is simply supposed to return blue pixels. It has been compiled to Shader Model 5.0 by changing its compile settings in Visual Studio 11. However upon running the program the triangle I am trying to render doesn't show up despite their being no build or runtime error messages.
When compiling at runtime using:
D3DCompileFromFile(L"PixelSHader.hlsl", 0, 0, "main", "ps_5_0", 0, 0, &PS_Buffer, 0);
instead of D3DReadFileToBlob(..), there is still no triangle rendered.
However when using Shader Model 4.0, whether buildtime or runtime compiled, a blue triangle does show signifying that it works.
Here is the code in my PixelShader.hlsl file. By any chance could it be too outdated for Shader Model 5.0 and be the root of my problem?
float4 main() : SV_TARGET
{
return float4(0.0f, 0.0f, 1.0f, 1.0f);
}
I am using the Windows SDK libraries and not the June 2010 DirectX SDK.
My Graphics Card is a nVidia 8800 GTS.
Shader model 5 is supported by the GeForce 400 series and newer for nVidia cards, and the Radeon 5000 series and newer for AMD cards. Your GeForce 8800 only supports shader model 4, which is why the shader doesn't run. To get around this you can use the reference device (by using D3D_DRIVER_TYPE_REFERENCE) but this will be quite slow. Additionally you can use the WARP device if you have the Windows 8 preview (which adds WARP support for D3D_FEATURE_LEVEL_11_0), which will perform better than the reference device but still nowhere near running on the hardware device.

Why i can not find my own image by cocos2d?

all.
I added my picture "Icon2222.png" into my project, and changed the name of picture from "grossini.png"(which is original) to "Icon2222.png",
but when I run the project, it crashed with the exception named NSInternalInconsistencyException and hint me that "Can't create Texture. UIImage is nil".
Where did I make a mistake? I just replaced a picture.
Thanks in advance.
2012-05-03 14:59:10.480 ActionManagerTest[3215:f803] cocos2d: cocos2d v1.0.1
2012-05-03 14:59:10.481 ActionManagerTest[3215:f803] cocos2d: Using Director Type:CCDirectorDisplayLink
2012-05-03 14:59:10.529 ActionManagerTest[3215:f803] cocos2d: OS version: 5.0 (0x05000000)
2012-05-03 14:59:10.529 ActionManagerTest[3215:f803] cocos2d: GL_VENDOR: Apple Computer, Inc.
2012-05-03 14:59:10.530 ActionManagerTest[3215:f803] cocos2d: GL_RENDERER: Apple Software Renderer
2012-05-03 14:59:10.531 ActionManagerTest[3215:f803] cocos2d: GL_VERSION: OpenGL ES-CM 1.1 APPLE
2012-05-03 14:59:10.531 ActionManagerTest[3215:f803] cocos2d: GL_MAX_TEXTURE_SIZE: 4096
2012-05-03 14:59:10.532 ActionManagerTest[3215:f803] cocos2d: GL_MAX_MODELVIEW_STACK_DEPTH: 16
2012-05-03 14:59:10.532 ActionManagerTest[3215:f803] cocos2d: GL_MAX_SAMPLES: 4
2012-05-03 14:59:10.533 ActionManagerTest[3215:f803] cocos2d: GL supports PVRTC: YES
2012-05-03 14:59:10.533 ActionManagerTest[3215:f803] cocos2d: GL supports BGRA8888 textures: YES
2012-05-03 14:59:10.534 ActionManagerTest[3215:f803] cocos2d: GL supports NPOT textures: YES
2012-05-03 14:59:10.535 ActionManagerTest[3215:f803] cocos2d: GL supports discard_framebuffer: YES
2012-05-03 14:59:10.535 ActionManagerTest[3215:f803] cocos2d: compiled with NPOT support: NO
2012-05-03 14:59:10.536 ActionManagerTest[3215:f803] cocos2d: compiled with VBO support in TextureAtlas : YES
2012-05-03 14:59:10.536 ActionManagerTest[3215:f803] cocos2d: compiled with Affine Matrix transformation in CCNode : YES
2012-05-03 14:59:10.537 ActionManagerTest[3215:f803] cocos2d: compiled with Profiling Support: NO
2012-05-03 14:59:10.549 ActionManagerTest[3215:f803] Retina Display Not supported
2012-05-03 14:59:10.550 ActionManagerTest[3215:f803] cocos2d: CCTexture2D. Can't create Texture. UIImage is nil
2012-05-03 14:59:10.551 ActionManagerTest[3215:f803] cocos2d: deallocing
[Switching to process 3215 thread 0x12f0b]
2012-05-03 14:59:10.551 ActionManagerTest[3215:f803] cocos2d: Couldn't add image:Icon2222.png in CCTextureCache
2012-05-03 14:59:10.559 ActionManagerTest[3215:f803] cocos2d: deallocing
2012-05-03 14:59:10.559 ActionManagerTest[3215:f803] * Assertion failure in -[CCLayer addChild:], /Users/qusean/Downloads/cocos2d-iphone-1.0.1/cocos2d/CCNode.m:413
2012-05-03 14:59:10.561 ActionManagerTest[3215:f803] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Argument must be non-nil'
* First throw call stack:
(0x17de052 0x14ddd0a 0x1786a78 0x1e92db 0xb300 0x4546 0x4adb0e 0x4ae8a6 0x4bd743 0x4be1f8 0x4b1aa9 0x1ed4fa9 0x17b21c5 0x1717022 0x171590a 0x1714db4 0x1714ccb 0x4ae2a7 0x4afa9b 0x2581 0x2505 0x1)
terminate called throwing an exception
Here is my code:
1
CCSprite *child = [CCSprite spriteWithFile:#"Icon2222.png"];
[child setPosition:ccp(200,200)];
[layer addChild:child];
2
CGSize winSize = [[CCDirector sharedDirector] winSize];
CCSprite *player = [CCSprite spriteWithFile:#"Icon2222.png"
rect:CGRectMake(0, 0, 27, 40)];
player.position = ccp(player.contentSize.width/2, winSize.height/2);
[layer addChild:player];
Both of them crashed.
I met the problem before.
The same happened Cause i changed the png name in the finder many times.
Use the original output png name which created by your Graphic tools will be smooth going.
wish it will be helpful
Delete the file from the bundle, then bring it back in with the correct file name. You are only changing the name of the file within the local project, not within the project directory.
I suggest you to clean the build... Delete the app.. And run again... In case it doesn't solve your problem... Remove all resources and add again to project...
Hope this helps.. :)
I know this thread is rather old, but i ran into same problem and my solution might help future lost souls.
My problem was that the file was not attached to the target and hence was not included and could not be found.
I.e. remember to make sure that the file is checked to be in your target in the Utility tab, or when you import the file.

Need help in resolving the simple cocos2d error?

I am using following code:
// Add the stuff from below!
CCSprite* background = [CCSprite spriteWithFile:#"background-1.png"];
background.tag = 1;
background.anchorPoint = CGPointMake(0, 0);
[self addChild:background];
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:
#"wave1.plist"];
CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode
batchNodeWithFile:#"wave1.png"];
[self addChild:spriteSheet];
NSMutableArray *walkAnimFrames = [NSMutableArray array];
for(int i = 1; i <= 8; ++i) {
[walkAnimFrames addObject:
[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
[NSString stringWithFormat:#"wave-r-l-000%d.png", i]]];
//wave-r-l-0001
}
CCAnimation *walkAnim = [CCAnimation
animationWithFrames:walkAnimFrames delay:0.1f];
CGSize winSize = [CCDirector sharedDirector].winSize;
self.bear = [CCSprite spriteWithSpriteFrameName:#"bear1.png"];
_bear.position = ccp(winSize.width/2, winSize.height/2);
self.walkAction = [CCRepeatForever actionWithAction:
[CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:NO]];
[_bear runAction:_walkAction];
[spriteSheet addChild:_bear];
But unfortunately it gives following error:
2011-07-12 09:43:33.471 TestBear[205:707] cocos2d: cocos2d v1.0.0-rc3
2011-07-12 09:43:33.479 TestBear[205:707] cocos2d: Using Director Type:CCDirectorDisplayLink
2011-07-12 09:43:33.650 TestBear[205:707] cocos2d: OS version: 4.3.1 (0x04030100)
2011-07-12 09:43:33.654 TestBear[205:707] cocos2d: GL_VENDOR: Imagination Technologies
2011-07-12 09:43:33.658 TestBear[205:707] cocos2d: GL_RENDERER: PowerVR SGX 535
2011-07-12 09:43:33.661 TestBear[205:707] cocos2d: GL_VERSION: OpenGL ES-CM 1.1 IMGSGX535-58.6
2011-07-12 09:43:33.667 TestBear[205:707] cocos2d: GL_MAX_TEXTURE_SIZE: 2048
2011-07-12 09:43:33.670 TestBear[205:707] cocos2d: GL_MAX_MODELVIEW_STACK_DEPTH: 16
2011-07-12 09:43:33.674 TestBear[205:707] cocos2d: GL_MAX_SAMPLES: 4
2011-07-12 09:43:33.677 TestBear[205:707] cocos2d: GL supports PVRTC: YES
2011-07-12 09:43:33.680 TestBear[205:707] cocos2d: GL supports BGRA8888 textures: YES
2011-07-12 09:43:33.684 TestBear[205:707] cocos2d: GL supports NPOT textures: YES
2011-07-12 09:43:33.687 TestBear[205:707] cocos2d: GL supports discard_framebuffer: YES
2011-07-12 09:43:33.690 TestBear[205:707] cocos2d: compiled with NPOT support: NO
2011-07-12 09:43:33.694 TestBear[205:707] cocos2d: compiled with VBO support in TextureAtlas : NO
2011-07-12 09:43:33.697 TestBear[205:707] cocos2d: compiled with Affine Matrix transformation in CCNode : YES
2011-07-12 09:43:33.700 TestBear[205:707] cocos2d: compiled with Profiling Support: NO
2011-07-12 09:43:33.854 TestBear[205:707] cocos2d: CCSpriteFrameCache: Trying to use file 'wave1.png' as texture
2011-07-12 09:43:33.905 TestBear[205:707] cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenerate the .plist
2011-07-12 09:43:33.910 TestBear[205:707] cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenerate the .plist
2011-07-12 09:43:33.914 TestBear[205:707] cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenerate the .plist
2011-07-12 09:43:33.917 TestBear[205:707] cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenerate the .plist
2011-07-12 09:43:33.921 TestBear[205:707] cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenerate the .plist
2011-07-12 09:43:33.925 TestBear[205:707] cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenerate the .plist
2011-07-12 09:43:33.928 TestBear[205:707] cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenerate the .plist
2011-07-12 09:43:33.932 TestBear[205:707] cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenerate the .plist
2011-07-12 09:43:33.935 TestBear[205:707] cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenerate the .plist
2011-07-12 09:43:33.941 TestBear[205:707] cocos2d: CCSpriteFrameCache: Frame 'bear1.png' not found
2011-07-12 09:43:33.946 TestBear[205:707] *** Assertion failure in -[CCSprite initWithSpriteFrame:], /Users/shahbazali/Documents/TestBear/libs/cocos2d/CCSprite.m:229
2011-07-12 09:43:34.006 TestBear[205:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid spriteFrame for sprite'
*** Call stack at first throw:
(
0 CoreFoundation 0x31fbe64f __exceptionPreprocess + 114
1 libobjc.A.dylib 0x31132c5d objc_exception_throw + 24
2 CoreFoundation 0x31fbe491 +[NSException raise:format:arguments:] + 68
3 Foundation 0x30c30573 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 62
4 TestBear 0x0008cf08 -[CCSprite initWithSpriteFrame:] + 200
5 TestBear 0x0008bfcc +[CCSprite spriteWithSpriteFrame:] + 88
6 TestBear 0x0008c098 +[CCSprite spriteWithSpriteFrameName:] + 120
7 TestBear 0x00003f04 -[HelloWorldLayer init] + 744
8 TestBear 0x00067bf0 +[CCNode node] + 76
9 TestBear 0x000041e4 +[HelloWorldLayer scene] + 100
10 TestBear 0x00003530 -[TestBearAppDelegate applicationDidFinishLaunching:] + 1028
11 UIKit 0x322f885d -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 832
12 UIKit 0x322f2b65 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 272
13 UIKit 0x322c77d7 -[UIApplication handleEvent:withNewEvent:] + 1114
14 UIKit 0x322c7215 -[UIApplication sendEvent:] + 44
15 UIKit 0x322c6c53 _UIApplicationHandleEvent + 5090
16 GraphicsServices 0x304a6e77 PurpleEventCallback + 666
17 CoreFoundation 0x31f95a97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
18 CoreFoundation 0x31f9783f __CFRunLoopDoSource1 + 166
19 CoreFoundation 0x31f9860d __CFRunLoopRun + 520
20 CoreFoundation 0x31f28ec3 CFRunLoopRunSpecific + 230
21 CoreFoundation 0x31f28dcb CFRunLoopRunInMode + 58
22 UIKit 0x322f1d49 -[UIApplication _run] + 372
23 UIKit 0x322ef807 UIApplicationMain + 670
24 TestBear 0x000030b4 main + 100
25 TestBear 0x00003018 start + 52
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
Please help
I know the topic is a bit old but it might help some people.
The error comes from this line:
self.bear = [CCSprite spriteWithSpriteFrameName:#"bear1.png"];
TestBear[205:707] cocos2d: CCSpriteFrameCache: Frame 'bear1.png' not found
It means that the CCSpriteFrameCache does not containt sprime frame named "bear1.png". Here you add only 1 plist file ("wave1.plist") and and it contains no sprime frame named "bear1.png". So check you plist file and re-generate it if necessary.
An another common error is to use "spriteWithSpriteFrameName:" instead of "spriteWithFile:" if your sprite is not inside a spritesheet.
I hope i'll help.