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

Author Topic: MacOSX Cocoa problems/questions  (Read 11113 times)

0 Members and 1 Guest are viewing this topic.

alaterale

  • Guest
MacOSX Cocoa problems/questions
« on: August 30, 2009, 10:51:29 pm »
Hi,
I've been using SFML for a while now, and I noticed that with the Cocoa port building, I always got errors about VideoMode in AppController and now GLKit.  I'm not really an objective c coder by any stretch (prefer C++), but I was kind of sick of seeing the warnings about incomplete definitions and such, so I fixed a couple things that were causing that (mainly turning 3 variables into variable pointers and adding new/deletes to init/deallocs).  I also found a better way of fixing that apple menu warning too (based off of SDL's way of fixing the warning).

I am unsure about how to submit patches to this system here, so I guess I can just attach it to this thread?  From what I've seen of the svn for 2.0 it looks like these things are still there (and I like to have a clean build log if I can help it :P).

The other question I have is: what is the cause of these errors?
Code: [Select]
2009-08-30 16:18:00.290 gamestone[4626:10b] *** _NSAutoreleaseNoPool(): Object 0xa20260 of class NSMenu autoreleased with no pool in place - just leaking
Stack: (0x9152af4f 0x91437432 0x950d5e21 0x95144d79 0x317b4e 0x318458 0x31d459 0x91f52dbc 0x91f52cb0 0x9529432b 0x951b4e8f 0x95263b64 0x95263869 0x952634ef 0x95261d94 0x9517eac7 0x316ae8 0x319077 0x31c6af 0x3c6375 0x399d4d 0x3a16b3 0x1a954 0x1bfd5 0xbbda 0x1832f 0x1a57a5 0x1d4092 0x1d7115 0x1d7903 0x1d7b07 0x2966c8 0x2975b3 0x3c6dd6 0x3c6a34 0x5a36)
2009-08-30 16:18:00.291 gamestone[4626:10b] *** _NSAutoreleaseNoPool(): Object 0xa0a620 of class NSCFNumber autoreleased with no pool in place - just leaking
Stack: (0x9152af4f 0x91437432 0x950c4394 0x951b76e2 0x95144fbd 0x317b4e 0x318458 0x31d459 0x91f52dbc 0x91f52cb0 0x9529432b 0x951b4e8f 0x95263b64 0x95263869 0x952634ef 0x95261d94 0x9517eac7 0x316ae8 0x319077 0x31c6af 0x3c6375 0x399d4d 0x3a16b3 0x1a954 0x1bfd5 0xbbda 0x1832f 0x1a57a5 0x1d4092 0x1d7115 0x1d7903 0x1d7b07 0x2966c8 0x2975b3 0x3c6dd6 0x3c6a34 0x5a36)
2009-08-30 16:18:00.292 gamestone[4626:10b] *** _NSAutoreleaseNoPool(): Object 0xaa0c90 of class NSConcreteAttributedString autoreleased with no pool in place - just leaking
Stack: (0x9152af4f 0x91437432 0x9511231d 0x951121b2 0x95112159 0x951b776c 0x951b773b 0x95144fbd 0x317b4e 0x318458 0x31d459 0x91f52dbc 0x91f52cb0 0x9529432b 0x951b4e8f 0x95263b64 0x95263869 0x952634ef 0x95261d94 0x9517eac7 0x316ae8 0x319077 0x31c6af 0x3c6375 0x399d4d 0x3a16b3 0x1a954 0x1bfd5 0xbbda 0x1832f 0x1a57a5 0x1d4092 0x1d7115 0x1d7903 0x1d7b07 0x2966c8 0x2975b3 0x3c6dd6 0x3c6a34 0x5a36)
2009-08-30 16:18:00.293 gamestone[4626:10b] *** _NSAutoreleaseNoPool(): Object 0xa99830 of class _NSThemeCloseWidget autoreleased with no pool in place - just leaking
Stack: (0x9152af4f 0x91437432 0x950cd696 0x950c33d1 0x950ccf86 0x95146695 0x905f3676 0x950d9adc 0x950d97e8 0x951b780a 0x951b778d 0x951b773b 0x95144fbd 0x317b4e 0x318458 0x31d459 0x91f52dbc 0x91f52cb0 0x9529432b 0x951b4e8f 0x95263b64 0x95263869 0x952634ef 0x95261d94 0x9517eac7 0x316ae8 0x319077 0x31c6af 0x3c6375 0x399d4d 0x3a16b3 0x1a954 0x1bfd5 0xbbda 0x1832f 0x1a57a5 0x1d4092 0x1d7115 0x1d7903 0x1d7b07 0x2966c8 0x2975b3 0x3c6dd6 0x3c6a34 0x5a36)
2009-08-30 16:18:00.293 gamestone[4626:10b] *** _NSAutoreleaseNoPool(): Object 0xa9c910 of class _NSThemeWidget autoreleased with no pool in place - just leaking


There are more of those, but I don't know how to fix those on my own.  Been looking around online for similar problems and finding what I could fix.  Is this the case in the latest 2.0 svn edition?

Thanks for any help, and if I can I will attach my edits so you can see whether its worthy enough to post as an official patch :)
Code: [Select]

alaterale

  • Guest
MacOSX Cocoa problems/questions
« Reply #1 on: August 30, 2009, 10:59:48 pm »
I guess I can't attach the patch files on this forum (maybe based on how new I am here)?

Well, here's my edit for the setAppleMenu thing, which is pretty similar to how I saw SDL handle it and get rid of the warning.

Code: [Select]

// MYEDITS
// For some reaon, Apple removed setAppleMenu from the headers in 10.4,
// but the method still is there and works. To avoid warnings, we declare
// it ourselves here.
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
@interface NSApplication(SFML_Missing_Methods)
- (void)setAppleMenu:(NSMenu *)menu;
@end
#endif

// MYEDITS
/* setAppleMenu disappeared from the headers in 10.4 */
//#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
//@interface NSApplication (SFML)
//- (void)setAppleMenu:(NSMenu *)menu;
//@end
//#endif


So I guess it's really just one line of change, and maybe you need it to be SFML there for objective C?  But this way removes the warning and my app still runs (though with those previous memory leaks or whatever).

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
MacOSX Cocoa problems/questions
« Reply #2 on: August 31, 2009, 01:13:28 am »
This declaration is there on purpose. AppController uses it so I don't understand why you want to comment it out ? The declaration allows the compiler to performs checks when I call this method.

As for the sfml2 branch, the Mac OS X port is absolutely not up to date. It's currently unusable.

And for the leaks... do you use the latest SVN sources ? (trunk)
If so, could you provide a minimal example producing these error messages ?

Thanks for your reports,
Ceylo
Want to play movies in your SFML application? Check out sfeMovie!

alaterale

  • Guest
MacOSX Cocoa problems/questions
« Reply #3 on: August 31, 2009, 01:27:47 am »
Well, all I really changed in that part was the "@interface NSApplication (SFML)" part.  It may be used, but the code as it is says that if you leave this in, it's "incomplete".  I didn't make up the part about Missing_methods.  I got that right from SDLMain.m, and it makes the warning go away, and my app still runs the same.  Though it might mess up the user menu or something, I dunno, I'm not really great at objectivec.  But I would imagine its giving a warning for a reason and what would be a better improvement to get rid of it?

If the SFML2 branch has a broken OSX port then I guess I can't use the SVN branch to see if the leaks go away, since I'm developing this on my mac.  As for what causes it, a minimal window opening does apparently.  I use SFML mainly for window/opengl contexts and input detection, and more recently the Audio stuff.  But I write my own opengl.  I don't have a specific example since its not a small codebase, but I just upgraded my engine to 1.5 and after the app finishes is where I get those errors.

Here's the link to the SVN repo I have if you want:
http://code.google.com/p/gamestone/source/browse/

alaterale

  • Guest
MacOSX Cocoa problems/questions
« Reply #4 on: August 31, 2009, 01:36:31 am »
Here are the other changes too I did:
http://code.google.com/p/gamestone/source/detail?r=600

I probably screwed up with the whole making those variables pointers, but I read online that the whole "user defined constructor" thing could be fixed by changing a C++ class variable to a pointer and adding init/dealloc stuff.

You're obviously more of a seasoned objc coder than me, does that make things worse or is basically the same?  Worked in 1.4 for me fine, and I didn't see those memory leak errors before.  I'll try to do some research on what could be causing that.  Learn more about objc all the time this way I guess :P

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
MacOSX Cocoa problems/questions
« Reply #5 on: August 31, 2009, 01:43:57 am »
I don't really understand. Are you saying that using "@interface NSApplication(SFML_Missing_Methods)" instead of "@interface NSApplication (SFML)" drops the warning away ?

If the warning is here, it is because the method is DEFINED but not DECLARED. If I ever redefine it, the original defined method will no more work.

As for the SVN repository, you can still use the sources of the trunk directory. These are the sources of SFML 1.6.
Want to play movies in your SFML application? Check out sfeMovie!

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
MacOSX Cocoa problems/questions
« Reply #6 on: August 31, 2009, 01:47:04 am »
Quote from: "alaterale"
Here are the other changes too I did:
http://code.google.com/p/gamestone/source/detail?r=600

I probably screwed up with the whole making those variables pointers, but I read online that the whole "user defined constructor" thing could be fixed by changing a C++ class variable to a pointer and adding init/dealloc stuff.

You're obviously more of a seasoned objc coder than me, does that make things worse or is basically the same?  Worked in 1.4 for me fine, and I didn't see those memory leak errors before.  I'll try to do some research on what could be causing that.  Learn more about objc all the time this way I guess :P

Things can indeed be fixed using new/delete stuff, but here it is useless and implies checking that the pointers being used are valid. By the way, the C++ constructors can be called when an Obj-C object declares a C++ member if a specific GCC option is used. But here again.. it's useless.
Want to play movies in your SFML application? Check out sfeMovie!

alaterale

  • Guest
MacOSX Cocoa problems/questions
« Reply #7 on: August 31, 2009, 01:50:08 am »
Yeah, rewriting that drops the warning away.  I knew it was probably more of a hack, so I'm not surprised there's a logical reason for it.  Well, either way, I'll probably keep my local hack of it to get rid of that annoying message popping up :P  What about the other additions?  The user defined constructor thing.  The only part about that which I'm unsure of, is that I don't know all the places where the variables would be constructed, so I might have missed a new or a delete, but it seems GCC likes having a pointer there instead of a regular variable.

Sorry about the confusion about the svn tree you have.  Here I thought the svn trunk was the stuff being prepared for 2.0.  Hehe, sorry bout that  :lol: I will get on that and see if the leak is still there (hopefully not).  Thanks!

alaterale

  • Guest
MacOSX Cocoa problems/questions
« Reply #8 on: August 31, 2009, 01:55:22 am »
Ok, sorry about the other fixes too.  Didn't know that there was a specific GCC flag for that kind of thing.  Sorry for bringing up useless ideas, just thought I'd help somehow.  Sorry for wasting your time  :( I will try the latest svn version too.  Thanks.

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
MacOSX Cocoa problems/questions
« Reply #9 on: August 31, 2009, 02:36:51 am »
Don't worry about bringing ideas ^^ . Just try to think why the things are what they are before changing everything to fit your ideas :P .

I'm waiting for your feedback with the sources of the latest svn version :) .
Want to play movies in your SFML application? Check out sfeMovie!

alaterale

  • Guest
MacOSX Cocoa problems/questions
« Reply #10 on: August 31, 2009, 02:52:31 am »
Heh, I understand.  I wasn't expecting others to change just to fit my ideas, but I like the idea of fixing warnings in the system.  It just seems weird to ignore warnings when you can find ways to fix them.  And I never thought my fixes were really good, since I'm still very unfamiliar with Objc :-P  Working on testing the latest svn trunk now, will get post back here when I get some results.

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
MacOSX Cocoa problems/questions
« Reply #11 on: August 31, 2009, 02:55:24 am »
Okay thanks !
Want to play movies in your SFML application? Check out sfeMovie!

alaterale

  • Guest
MacOSX Cocoa problems/questions
« Reply #12 on: August 31, 2009, 03:14:03 am »
Yes, updating to SVN does fix that weird pool/leak error, but now I get a different one:

Code: [Select]
2009-08-30 21:11:48.311 gamestone[1520:10b] CGSAddSurface failed - error 1001 (windowID:70)

But at least it's not a couple pages of huge error codes.

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
MacOSX Cocoa problems/questions
« Reply #13 on: August 31, 2009, 10:28:49 am »
Can you provide a minimal code producing this error ?
Want to play movies in your SFML application? Check out sfeMovie!

alaterale

  • Guest
MacOSX Cocoa problems/questions
« Reply #14 on: August 31, 2009, 11:34:19 am »
I'm already up really late and tired, but I think I've pinned it down further as to what might be causing it (if my brain could be considered functional now :P).  A "minimal" code sample is not that easy as the engine is running python scripts, and it can be a bit large to understand the whole layout.  But here is a portion my main loop:

Code: [Select]

  // Create the window
  Create(title, width, height, bpp, depth, stencil, antialiasing);
 
  // Check that it opened correctly
  if (!IsOpened())
  {
    printf("ERROR: Window could not be opened\n");
    return;
  }
 
  // Set maximum framerate
  SetFramerateLimit(maxfps);
 
  // Enable VSync
  EnableVerticalSync(true);
 
  // Enable key repeat
  EnableKeyRepeat(false);
 
  // Initialize OpenGL
  InitializeGL();
 
  // Initialize state
  InitializeState();
 
  // Swap buffers
  Display();
 
  // Start main loop
  while (IsRunning())
  {
    // Process events
    while (IsEventFull())
    {
      // Window close
      if (GetEventType() == SCREEN_EVENT_CLOSED)
      {
        // End game
        EndGame();
      }
     
      // Check input from controllers
      CheckInput();
    }
   
    // Update State
    InputState();
    UpdateState();
   
    // Swap buffers
    Display();


Now, I have a thin wrapper around SFML stuff, so that's why those methods are different than the standard ones.  The error pops up only when closing the program with Command Q.  If I close it with checking the red close button, or do a command W and then command Q, it doesn't occur.  So it might be something in the registered quit command (the apple menu one, that is autogenerated, because I know I didn't code it :P).  A program on my end that is just a simple print hello world still does it (just an empty graphical window).  With the above input checking code commented out still creates the error.  When the IsEventFull (which just calls window.GetEvent(event)) part commented out, it becomes impossible to close the app without hard forcing it.

I hope this info is useful.  Of course the source code is online too in those previous links I gave you in case you need to look at something else.

Now off to sleep (hate insomnia) :P

 

anything