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 1249 - Crash when more than one program use SDL at same time
Summary: Crash when more than one program use SDL at same time
Status: RESOLVED WONTFIX
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: x86 Windows 7
: P2 major
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-20 14:34 UTC by Jeff Shanab
Modified: 2013-05-22 00:01 UTC (History)
1 user (show)

See Also:


Attachments
Screenshot of backtrace and SDL code (281.92 KB, image/png)
2011-07-20 14:35 UTC, Jeff Shanab
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff Shanab 2011-07-20 14:34:34 UTC
Attempting to start a second program using SDL-1.3 is failing in a simple init.
App here is displaying yuv video using a streaming texture.
When the second instance is called it fails in CreateRenderer as the attached backtrace shows.

Windows 7 SDL-1.3 Cloned ~7/15
C++ code in a browser plugin playing video.
Works fine in 14 threads in one process but fails in second process.
 
basic init func:

int ClassName::InitSDL()
	{
		if (SDL_Init(SDL_INIT_VIDEO) < 0) {
			fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
			return -1;
		}
		

		UINT width = rect_.right - rect_.left;
		UINT height = rect_.bottom - rect_.top;
		
		window_ = SDL_CreateWindowFrom(wnd_);

		if (!window_) {
			fprintf(stderr, "Couldn't set create window: %s\n", SDL_GetError());
			return -3;
		}

		renderer_ = SDL_CreateRenderer(window_, -1, SDL_RENDERER_ACCELERATED);
		if (!renderer_) {
			fprintf(stderr, "Couldn't set create renderer: %s\n", SDL_GetError());
			return -4;
		}

		//wait for first frame to be decoded , need escape
		if (!started_)
		{
			scoped_lock lock(firstDecodeMutex_);
			firstDecodeCond_.wait(lock);
		}
		if (started_)
		{
	

			VideoTexture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_YV12, SDL_TEXTUREACCESS_STREAMING, pCodecCtx_->width,pCodecCtx_->height);
			if (!VideoTexture_) {
				fprintf(stderr, "Couldn't set create texture: %s\n", SDL_GetError());
				return -5;
			}
			initialized_ = true;
		}
		return 0;
	}
Comment 1 Jeff Shanab 2011-07-20 14:35:44 UTC
Created attachment 651 [details]
Screenshot of backtrace and SDL code
Comment 2 Sam Lantinga 2011-12-29 02:46:10 UTC
This doesn't make any sense to me.  Why would the pointers to display modes be invalid in the second process?  Did you have any luck tracking this one down?
Comment 3 Sam Lantinga 2013-05-21 02:46:31 UTC
No response in 2 years, closing bug.

Please feel free to reopen this bug if it's still active in the current snapshot:
http://www.libsdl.org/tmp/SDL-2.0.zip

Thanks!
Comment 4 Jeff Shanab 2013-05-21 08:20:06 UTC
Sorry about the delay, I missed the interveaning notifications somehow.

The issue is that browsers spawn a process but when the window is handed of the context (DX or GL) is no longer connected.

Win 7 introduced a window class pool and while the pointer stays the same, the OS is free to return/reallocate from the pool. Things you attach to the window can get disconnected.

Only solution for now has been to force the plugin to run "in process"
Adobe Flash had this same problem and "fixed" it but they did not share how they fixed it. 

But this is why we do not support chrome browser at the moment, it allows such reassignment on scroll and resize and crashes.
Comment 5 Sam Lantinga 2013-05-22 00:01:06 UTC
Let me know if there's anything SDL can do to help here.