We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1209

Summary: sdl initializes too long -> loading bmp doesnt work (?)
Product: SDL Reporter: PJ <winhelp>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED WONTFIX QA Contact: Sam Lantinga <slouken>
Severity: minor    
Priority: P2    
Version: 1.2.14   
Hardware: x86   
OS: Linux   
Attachments: small image
Test program based on the pastebin example.

Description PJ 2011-05-23 09:40:16 UTC
Created attachment 613 [details]
small image

Hey,
it seems that SDL_LoadBMP doesn't work properly if the surface we are creating is too small. It happens with this code:
http://pastebin.com/02WcsrY8
It should show an image 75x75 for two seconds. The problem is, that it shows only the black window, but apart from that everything is fine - there is no errors or something.

I tried it on a few different computers and it sometimes shows this image and sometimes not - but what is really strange, when I add even a small delay before SDL_BlitSurface it ALWAYS shows the picture correctly. In my case, adding SDL_Delay(100) worked. It looks like too long initalizing causes this(maybe i call LoadBMP too early? I don't know).

I believe that the specific image doesn't matter in this case(maybe picture must be really small or something), but i attach this image in case I am wrong.

I think it's not so important bug(such small windows are used rarely :P), but it is strange anyway and i think you should know about it.

http://stackoverflow.com/questions/5865194/sdl-framework-can-not-show-bmp-files-smaller-than-20x20-pixels - it looks very similar to this bug :P

Sorry for bad English but i hope i will be understood.
Comment 1 Sam Lantinga 2011-12-29 01:40:33 UTC
Thanks for the report.  Please let me know if you have a patch for this issue!
Comment 2 Ryan C. Gordon 2011-12-30 00:04:14 UTC
Created attachment 748 [details]
Test program based on the pastebin example.


Just looked at this, and it _does_ fail to render, as reported...rather, it rendered just the top corner of the image on my computer.

However, if you pump the event queue, it renders the rest of it. See attached program that adds an event loop after the two-second delay. You'll see the image render after the delay is done.

So, strictly speaking, this _might_ be an X11-specific SDL bug, but I'm inclined to say it's not worth fixing, as any reasonable program will have an event loop.

Running it under valgrind without the event loop causes the bug to go away, too...race condition with the X server?

My guess as to the issue is that we have pending X11 data that hasn't been XFlush()'d, so running the even loop later pushes that data down the pipe. A bigger image will force a flush sooner, avoiding this problem. Or something. I'm not sure.

I think this is appropriate to leave as WONTFIX. It should only happen in small test programs like this.

--ryan.