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

Author Topic: pollEvent crash after window re-create (osx)  (Read 4696 times)

0 Members and 1 Guest are viewing this topic.

moonfirefly

  • Newbie
  • *
  • Posts: 28
    • View Profile
pollEvent crash after window re-create (osx)
« on: August 23, 2014, 06:52:31 am »
I get a crash on pollEvent after re-creating the window, immediately after I do a command+tab while moving the mouse or trackpad. It looks like input events are polled on a resource that has been deallocated upon re-creating the window.

Here's a small example that triggers the problem every single time on my macbook with these steps:
  • Run example
  • Press 'F' key to trigger a window re-create
  • Press command+tab to lose window focus while moving mouse/trackpad
Example source:
(click to show/hide)

The exception as it occurs in Xcode:
(click to show/hide)

The crash log with a test outside Xcode:
(click to show/hide)

The issue occurs even if the resolution is not changed or using different styles. I compiled SFML from source as of today. I did try to re-create the window outside the pollEvent loop but still get the crash at the next pollEvent call.

Note that doing plenty of command+tab and mouse events without window re-creation does not trigger the problem.

Am I doing something wrong here?
Blokade: Source

Strelok

  • Full Member
  • ***
  • Posts: 139
    • View Profile
    • GitHub
Re: pollEvent crash after window re-create (osx)
« Reply #1 on: August 23, 2014, 07:58:58 am »
It keeps recreating the window as soon as you press F once.
Toggle must be declared in the is open loop and yes, the window create is (probably?) better off of the poll event loop

moonfirefly

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: pollEvent crash after window re-create (osx)
« Reply #2 on: August 23, 2014, 05:11:18 pm »
Quote
It keeps recreating the window as soon as you press F once.
It doesn't, did you run the example?

Quote
Toggle must be declared in the is open loop
Toggle in this case is not a trigger, it designates state, thus is outside the loop.

Quote
and yes, the window create is (probably?) better off of the poll event loop
As mentioned, I did try this option to no avail and posted the simpler example for simplicity.

Out of due diligence, here's another complete example with the window re-create outside the event loop that still triggers the problem:
(click to show/hide)
Blokade: Source

Strelok

  • Full Member
  • ***
  • Posts: 139
    • View Profile
    • GitHub
Re: pollEvent crash after window re-create (osx)
« Reply #3 on: August 23, 2014, 09:22:38 pm »
You're completely right, I should learn not to lurk the forums while I am only half awake. I apologize for sounding like a smartass and not helping you a single bit  :'(.
Let me try again (I know nothing about OSX but no one seems to reply and I have a lot of time to waste):
« Last Edit: August 23, 2014, 09:47:52 pm by Strelok »

moonfirefly

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: pollEvent crash after window re-create (osx)
« Reply #4 on: August 24, 2014, 12:41:05 am »
Quote
Random (most likely totally unrelated) URL
I have no idea if the autorelease wrapper is in cause or not. Either way I have no control over it.

Quote
Are you compiling in debug or release mode?
Compiling in debug or release mode yields to the same result.

Quote
The code has a lot of error messages and it's weird nothing happens before the crash.
There's a stack trace in the crash log but there are no error messages, just a general protection fault. On my end at least.
Blokade: Source

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: pollEvent crash after window re-create (osx)
« Reply #5 on: August 25, 2014, 04:16:46 pm »
I just tried the second code sample you gave but could not reproduce the issue.

When you compiled SFML on the 23rd, did you remove any previous binary from your system? Maybe there's a bad mix going on..

EDIT: hum.. in fact I could reproduce it a few times.. but it's very strange... I'll try to have a look.
« Last Edit: August 25, 2014, 04:21:54 pm by Hiura »
SFML / OS X developer

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: pollEvent crash after window re-create (osx)
« Reply #6 on: August 25, 2014, 04:49:49 pm »
After a bit of git bisect I think I found the issue. Can you confirm that replacing line 219 in src/Window/OSX/WindowImplCocoa.mm with

            [NSApp setDelegate:[[SFApplicationDelegate alloc] init]];

fix the issue?
SFML / OS X developer

moonfirefly

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: pollEvent crash after window re-create (osx)
« Reply #7 on: August 25, 2014, 11:47:33 pm »
Success! I cannot reproduce the problem anymore, I'll do further tests but it looks good  :)

It wasn't line 219 exactly but I figured you removed the autorelease.

Here's my exact change:
(click to show/hide)

Thanks a lot! :D
Blokade: Source

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: pollEvent crash after window re-create (osx)
« Reply #8 on: August 26, 2014, 11:02:06 am »
Great, thanks for your help. I'll include a patch soon together with issue #672.
SFML / OS X developer

 

anything