Weird rendering in 64-bit build only under OS X 10.9

Hello,

I’m using SDL2 in the framework of a small cross-platform tool to render a webcam preview. In OS X (my test platform is a vmware’s VM with OS X 10.9 Mavericks – no choice, I don’t have any real Mac at hand currently), it works well with a 32-bit build (ie. i386), but not with the 64-bit (aka. x86_64) one: the first frame is displayed with large diagonale streaks in the half right/bottom part (triangle) and following frames are simply ignored.

I’m using the SDL_LockTexture/SDL_UnlockTexture way to update the texture when a new frame arrives from the camera. I made an attempt with renderer created with SDL_RENDERER_ACCELERATED and SDL_RENDERER_SOFTWARE flags: no change!

I first tried with an SDL2 coming from homebrew, then I uninstalled this version and I built the current release (SDL2-2.0.8.tar.gz) as Fat/Universal (32 + 64-bit) by myself… Same result! I also tried against shared and static libs (ie. libSDL2.a and libSDL2main.a) and it doesn’t change the result.

So, does it’s an issue because of OS X in a VM (but, then, why it well works with a 32-bit build) or a known issue about SDL2 in OS X? What do you think?

Well, I reduced to a minimal test code (here, loading a BMP file to get ride of all the webcam stuff, but keeping the way I display it – through texture).

#include <sdl2/sdl.h>

int main()
{
  int w = 512; int h = 512;

  SDL_Init(SDL_INIT_VIDEO);

  SDL_Window* wnd = SDL_CreateWindow("Preview", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w, h, 0);
  SDL_Renderer* renderer = SDL_CreateRenderer(wnd, -1, SDL_RENDERER_ACCELERATED);
  SDL_Surface* surface = SDL_LoadBMP("test.bmp");
  SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, surface);
  SDL_RenderCopy(renderer, texture, NULL, NULL);
  SDL_RenderPresent(renderer);

  getchar(); /* just to see the result */

  SDL_DestroyTexture(texture);
  SDL_FreeSurface(surface);
  SDL_DestroyRenderer(renderer);
  SDL_DestroyWindow(wnd);
  SDL_Quit();
  return 0;
}

Here are the results (when built in 32-bit at left side, and in 64-bit at right side):

Here, how I built them:
clang -arch i386 test.c -L/usr/local/lib -lsdl2 -o test32
clang -arch x86_64 test.c -L/usr/local/lib -lsdl2 -o test64

EDIT: OK, it only does this with OS X 10.9 Mavericks. Tried in others VMs with 10.10 Yosemite and 10.12 Sierra and it’s all OK. In another VM with 10.9 Mavericks, it does the same; so it’s not something specificaly broken in a single VM with OS X 10.9. Also, I noticed it (the culprit 64-bit build) works one time after a fresh reboot, then all following calls fail as show in the right-side image above. It would be interesting to know if this issue appears in a real Mac with OS X 10.9 Mavericks…

It looks like this should work. Can you report a bug on http://bugzilla.libsdl.org and include the source above, along with test.bmp so we can try to reproduce it?

Thanks!

No problem to report it in your bug tracker, but at this time Bugzilla seems to fail to send me the confirmation email (and nothing in spam folder, of course).

Can you post a link to your test image, in the meantime?

Thanks!

Yep, here it is : http://eeweb.poly.edu/~yao/EL5123/image/lena_gray.bmp

Hello, renewed my registration on bugzilla.libsdl.org and never received any confirmation email. So, maybe you should take a look in your logs to see if nothing goes wrong (maybe because my email address contains a “dot” in the username part or blacklister domain, don’t know)… Well, just so you know.