Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Error destroying window in Mac when rendering in non-main thread  (Read 7776 times)

0 Members and 1 Guest are viewing this topic.

Pablo

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: AW: Error destroying window in Mac when rendering in non-main thread
« Reply #15 on: January 28, 2015, 07:56:09 pm »
Looks indeed like an issue in the OS X implementation. Time to wait for Hirua's comment. ;)

Two points about your code:
* bool is not an atomic type and operations on it require synchronization as well, or you use the C++11 atomic symbols.
* Keep in mind that std::hash's hashing algorithm is compiler/toolchain specific and it's not always very good.

Thanks for the feedback, I didn't know about the hash being compiler/toolchain specific. I just used that because I googled how to print the current thread id and I thought it was the proper way of doing it in C++11. Anyway, I just wanted to print unambiguously each thread.

I kept the exitThreadFlag simple for the sake of the minimal example. Although the behavior of reading/writing concurrently the same bool is not defined, as far as I understand, for this example in the worst case you'd be running 1 extra iteration within the loop, which doesn't seem to be a ver big problem in this case. But yes, in case you're doing more complicated things and even if you're not a purist coder, you'd better protect every shareable zone with something to avoid race conditions.

Quote
Hey Hey, thanks for the *proper* bug report. It's not everyday I get something that clear about a bug. So let's focus on the issue at hand and not digress on opinion based topic about MT programming, shall we? :-)

BTW, to debug things, use your debugger, it's way faster since you don't need to edit code to add prints. In this case, I added breakpoints in releasePool() and retainPool() that automatically continue executing code after executing bt -c 0 (print only the header of the backtrace) and I get the following:

You're welcome. Thanks for the advice and for working to figure out the workaround :D. The thing is that I didn't have the SFML project loaded into my IDE  (so that I can debug with it, as I have no idea of using gdb manually) and wasn't setting correctly the breakpoints. Also, I come from the embedded software world where most of the times you cannot really debug in real-time, so I'm used to prepare some logs the moment I have any issue debugging. In any case, you're right, it's way faster to use the debug, because it also provides you with tons of information quite complex to gather of any other way. I'd rather had invested some time importing the project into my IDE, though  8)

BTW, the sf::Shader::isAvailable() trick works like a charm, thanks a million.
« Last Edit: January 28, 2015, 11:11:11 pm by Pablo »

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Error destroying window in Mac when rendering in non-main thread
« Reply #16 on: January 29, 2015, 03:31:06 pm »
Thanks for confirming the workaround is working.

I've opened #790 to keep track of this issue but I don't know (yet) how I'll fix that... :/
SFML / OS X developer

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Error destroying window in Mac when rendering in non-main thread
« Reply #17 on: September 08, 2015, 10:59:11 am »
Patch available: could you head over https://github.com/SFML/SFML/pull/962 and give it a try? Thanks
SFML / OS X developer

Pablo

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Error destroying window in Mac when rendering in non-main thread
« Reply #18 on: September 11, 2015, 06:48:05 pm »
Patch available: could you head over https://github.com/SFML/SFML/pull/962 and give it a try? Thanks

I have just checked it out and it works like a charm in both release and debug versions. Thanks a million for the hard work, Hiura  ;)

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Error destroying window in Mac when rendering in non-main thread
« Reply #19 on: September 12, 2015, 11:40:11 am »
Great! Thanks for your feedback.  :)
SFML / OS X developer

 

anything