SDL_CreateRenderer crash

478 views
Skip to first unread message

comput...@gmail.com

unread,
Nov 24, 2015, 2:23:52 AM11/24/15
to Native-Client-Discuss
hi,all 

when i used SDL (2.0.3) to show the video data which is decoded by ffmpeg  in NACL ,it's crashed.

……

SDL_Window *screen;
SDL_Renderer* sdlRenderer; 
SDL_SetMainReady();
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER)) 
{    
        printf( "Could not initialize SDL - %s\n", SDL_GetError());          
screen = SDL_CreateWindow("Simplest ffmpeg player's Window", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 384, 288, SDL_WINDOW_OPENGL);
if(!screen) 
{    
        printf("SDL: could not create window - exiting:%s\n",SDL_GetError());         
}

sdlRenderer = SDL_CreateRenderer(screen, -1, 0);    //crashed
if(!sdlRenderer)
{    
        printf("SDL: could not create Renderer - exiting:%s\n",SDL_GetError());             
}  

And when i list the renders,there are two render: code
int numdrivers = SDL_GetNumRenderDrivers (); int i = 0; printf("Render driver count:%d.\n",numdrivers); for (; i<numdrivers; i++) { SDL_RendererInfo drinfo; SDL_GetRenderDriverInfo (i, &drinfo); printf("Driver name %d : %s\n",i,drinfo.name); if (drinfo.flags & SDL_RENDERER_SOFTWARE) { printf("the renderer is a software fallback \n"); } if (drinfo.flags & SDL_RENDERER_ACCELERATED) { printf("the renderer is a hardware acceleration \n"); } if (drinfo.flags & SDL_RENDERER_PRESENTVSYNC) { printf("present is synchronized with the refresh rate \n"); } if (drinfo.flags & SDL_RENDERER_TARGETTEXTURE) { printf("the renderer supports rendering to texture \n"); } }

the result:
Render driver count:2. Driver name 0 : opengles2 the renderer is a hardware acceleration present is synchronized with the refresh rate the renderer supports rendering to texture Driver name 1 : software the renderer is a software fallback the renderer supports rendering to texture 

is there anybody can help me?
thanks.

dellwyse...@gmail.com

unread,
Dec 7, 2015, 5:12:50 PM12/7/15
to Native-Client-Discuss
Same here. See my last post on SDL2
Hi Sam,
Just inform you that we found the cause of the crash in the SDL API: SDL_CreateRenderer().
We built teststeaming.c, PNACL toolchain with PEPPER_44 or 45 on naclports "pepper_44" github branch.

The SDL_CreateRendere() crashes due to the codes for NACL is not defined in SDL_render_gles2.c.
Any reason why these codes have not been enabled for building  SDL2 lib ?
Thanks

/naclports/out/build/sdl2/sdl2-2.0.3/src/render/opengles2/SDL_render_gles2.c
Add to GLES2_LoadFunctions(GLES2_DriverContext * data) the case define for SDL_VIDEO_NACL
#elif SDL_VIDEO_DRIVER_NACL
#define __SDL_NOGETPROCADDR__

static int GLES2_LoadFunctions(GLES2_DriverContext * data)
{
#if SDL_VIDEO_DRIVER_UIKIT
#define __SDL_NOGETPROCADDR__
#elif SDL_VIDEO_DRIVER_ANDROID
#define __SDL_NOGETPROCADDR__
#elif SDL_VIDEO_DRIVER_PANDORA
#define __SDL_NOGETPROCADDR__
#elif SDL_VIDEO_DRIVER_NACL
#define __SDL_NOGETPROCADDR__
#endif

#if defined __SDL_NOGETPROCADDR__
#define SDL_PROC(ret,func,params) data->func=func;
#else
#define SDL_PROC(ret,func,params) \
    do { \
        data->func = SDL_GL_GetProcAddress(#func); \
        if ( ! data->func ) { \
            return SDL_SetError("Couldn't load GLES2 function %s: %s\n", #func, SDL_GetError()); \
        } \
    } while ( 0 );
#endif /* _SDL_NOGETPROCADDR_ */
- show quoted text -

Sam Clegg

unread,
Dec 7, 2015, 6:59:38 PM12/7/15
to native-cli...@googlegroups.com
On Mon, Dec 7, 2015 at 2:12 PM, <dellwyse...@gmail.com> wrote:
> Same here. See my last post on SDL2
> Hi Sam,
> Just inform you that we found the cause of the crash in the SDL API:
> SDL_CreateRenderer().
> We built teststeaming.c, PNACL toolchain with PEPPER_44 or 45 on naclports
> "pepper_44" github branch.
> https://chromium.googlesource.com/external/naclports.git/+/pepper_44
>
> The SDL_CreateRendere() crashes due to the codes for NACL is not defined in
> SDL_render_gles2.c.
> Any reason why these codes have not been enabled for building SDL2 lib ?

I guess you mean why is __SDL_NOGETPROCADDR__ defined for the NaCl port?

I didn't write that code (or if I did it was long time ago now), but
it looks like some platforms get the GLES2 symbols dynamically, and
others rely on the linker to provide them statically. Under NaCl the
GLES2 symbols are available statically at link time. If they were not
present then you would link errors.

What is the crash you are seeing? Are some of the GLES2 functions
resolving to NULL, or are they crashing when you call them?

cheers,
sam
> --
> You received this message because you are subscribed to the Google Groups
> "Native-Client-Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to native-client-di...@googlegroups.com.
> To post to this group, send email to native-cli...@googlegroups.com.
> Visit this group at http://groups.google.com/group/native-client-discuss.
> For more options, visit https://groups.google.com/d/optout.

dellwyse...@gmail.com

unread,
Dec 7, 2015, 8:23:49 PM12/7/15
to Native-Client-Discuss
Yes Sam,
The moment the SDL teststreaming app calling SDL_CreateRenderer() it got NACL module crashed.
The GLES2 functions is NULL.

When I added the define for NACL and rebuilt the SDL2 libs, it worked fine since now.
/naclports/out/build/sdl2/sdl2-2.0.3/src/render/opengles2/SDL_render_gles2.c
#elif SDL_VIDEO_DRIVER_NACL
#define __SDL_NOGETPROCADDR__
#endif


BL

unread,
Feb 28, 2016, 12:40:20 PM2/28/16
to Native-Client-Discuss
Hi,
I synced up the latest webports and built SDL2 with pepper_49 SDK, build my SDL2 app and still get the crash at SDL_CreateRenderer().
To fix the crash, again I need to change to the SDL2 source codes opengles2,c and define SDL_VIDEO_DRIVER_NACL.
Any reason why we still need to do this ?

/naclports/out/build/sdl2/sdl2-2.0.3/src/render/opengles2/SDL_render_gles2.c
Add to GLES2_LoadFunctions(GLES2_DriverContext * data) the case define for SDL_VIDEO_NACL
#elif SDL_VIDEO_DRIVER_NACL
#define __SDL_NOGETPROCADDR__

static int GLES2_LoadFunctions(GLES2_DriverContext * data)
{
#if SDL_VIDEO_DRIVER_UIKIT
#define __SDL_NOGETPROCADDR__
#elif SDL_VIDEO_DRIVER_ANDROID
#define __SDL_NOGETPROCADDR__
#elif SDL_VIDEO_DRIVER_PANDORA
#define __SDL_NOGETPROCADDR__
#elif SDL_VIDEO_DRIVER_NACL
#define __SDL_NOGETPROCADDR__
#endif


Sam Clegg

unread,
Mar 1, 2016, 2:48:52 PM3/1/16
to native-cli...@googlegroups.com
On Sun, Feb 28, 2016 at 9:40 AM, BL <mele...@gmail.com> wrote:
> Hi,
> I synced up the latest webports and built SDL2 with pepper_49 SDK, build my
> SDL2 app and still get the crash at SDL_CreateRenderer().
> To fix the crash, again I need to change to the SDL2 source codes
> opengles2,c and define SDL_VIDEO_DRIVER_NACL.
> Any reason why we still need to do this ?

I suppose that nobody fixed the SDL2 port yet. If you have a fix
please feel free to contribute it back (see
https://chromium.googlesource.com/webports/+/master/CONTRIBUTING.md).
It would also be nice to get some automatic tested added to avoid such
breakages in the future (see
https://chromium.googlesource.com/webports/+/master/chrome_test/).
>>> > email to native-client-di...@googlegroups.com.
>>> > To post to this group, send email to native-cli...@googlegroups.com.
>>> > Visit this group at
>>> > http://groups.google.com/group/native-client-discuss.
>>> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Native-Client-Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to native-client-di...@googlegroups.com.
> To post to this group, send email to native-cli...@googlegroups.com.
> Visit this group at https://groups.google.com/group/native-client-discuss.
Reply all
Reply to author
Forward
0 new messages