Opened 5 months ago

Last modified 4 months ago

#15688 reopened defect

Mac 10.5 & 10.6: ShowModal never returns when called from wxApp::OnInit()

Reported by: joostn Owned by: csomor
Priority: normal Milestone:
Component: wxOSX-Cocoa Version: 3.0.0
Keywords: wxApp::OnInit dialog ShowModal Cc: joost@…
Blocked By: Blocking:
Patch: no

Description

If I show a dialog in OnInit, ShowModal never returns. The problem occurs on OSX 10.5. I have not tested 10.6.
OSX 10.7 and later seem to work fine.
Here's my OnInit (a full sample cpp is attached):

bool MyApp::OnInit()
{
    if ( !wxApp::OnInit() ) return false;

    wxDialog dlg1(NULL, -1, wxT("Dialog 1"));
    dlg1.ShowModal();

    // On 10.5 we never get here:
    wxDialog dlg2(NULL, -1, wxT("Dialog 2"));
    dlg2.ShowModal();
    return false;
}

My wx library and the app is built on a 10.9 machine against the 10.9 SDK, with macosx-version-min set to 10.5:

../configure --enable-debug --with-macosx-sdk="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" --with-macosx-version-min=10.5 --with-expat=builtin --enable-unicode --disable-shared --disable-compat26 --disable-compat28 --with-osx-cocoa --without-liblzma --with-zlib=builtin

Here's a sample of the hanging process on 10.5 (after closing the first dialog box):

Sampling process 126 for 3 seconds with 1 millisecond of run time between samples
Sampling completed, processing symbols...
Analysis of sampling minimal (pid 126) every 1 millisecond
Call graph:
    2065 Thread_2507
      2065 start
        2065 main
          2065 wxEntry(int&, char**)
            2065 wxEntry(int&, wchar_t**)
              2065 wxApp::CallOnInit()
                2065 MyApp::OnInit()
                  2065 wxDialog::ShowModal()
                    2065 wxModalEventLoop::Run()
                      2065 wxEventLoopBase::Run()
                        2065 wxCFEventLoop::DoRun()
                          2065 wxModalEventLoop::OSXDoRun()
                            2065 -[NSApplication runModalForWindow:]
                              2065 -[NSApplication _realDoModalLoop:peek:]
                                2065 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]
                                  2065 _DPSNextEvent
                                    2065 BlockUntilNextEventMatchingListInMode
                                      2065 ReceiveNextEventCommon
                                        2065 RunCurrentEventLoopInMode
                                          2065 CFRunLoopRunSpecific
                                            2065 mach_msg
                                              2065 mach_msg_trap
                                                2065 mach_msg_trap

Total number in stack (recursive counted multiple, when >=5):

Sort by top of stack, same collapsed (when >= 5):
        mach_msg_trap        2065
Sample analysis of process 126 written to file /dev/stdout

Attachments (1)

minimal.cpp download (367 bytes) - added by joostn 5 months ago.
minimal sample

Download all attachments as: .zip

Change History (18)

Changed 5 months ago by joostn

minimal sample

comment:1 Changed 5 months ago by joostn

  • Cc joost@… added

comment:2 Changed 5 months ago by TomMettam2

This works fine on MSW, must be cocoa specific.

comment:3 Changed 5 months ago by csomor

  • Status changed from new to infoneeded_new

oh dear, 10.5 … , ppc or i386 ?

comment:4 Changed 5 months ago by joostn

  • Status changed from infoneeded_new to new

No, plain old x86_64.. Haven't tried i386 yet. I don't care about ppc anymore but I'd like to continue to support 10.5 for intel macs.

If I remove the startup dialogs my application seems to run perfectly (including any modal dialogs launched later on), this seems to be the only problem.

Looking at the stack trace it seems stopModal is not fired or it is ignored? If you have any hints I'd be happy to try something.

comment:5 Changed 5 months ago by csomor

  • Owner set to csomor
  • Status changed from new to accepted

I've gone lengths to make sure modal dialogs work from OnInit from Cocoa, but we might have to special case things for earlier systems … what would be helpful is if you could test unter 10.6.8 so that we know about the reach of the problem. I'll have to think about which options I have

comment:6 Changed 5 months ago by joostn

Problem occurs on i386 as well. And I'm running 10.5.8 actually.

I'll set up a 10.6 machine and let you know.

comment:7 Changed 5 months ago by joostn

OK, tried it on OSX 10.6.8: this is affected as well. First dialog shows but the second does not appear.

comment:8 Changed 5 months ago by joostn

  • Summary changed from Mac 10.5: ShowModal never returns when called from wxApp::OnInit() to Mac 10.5 & 10.6: ShowModal never returns when called from wxApp::OnInit()

comment:9 Changed 5 months ago by csomor

thanks a lot for testing

comment:10 Changed 4 months ago by plorkyeran

I'm seeing the same behavior on 10.7 as well, using wx 3.0.0 compiled on 10.9 with the 10.9 SDK, -mmacosx-version-min=10.7 and libc++.

comment:11 Changed 4 months ago by csomor

very strange, could you please retest with svn trunk, I've just rebuilt the sample with the patch using xcode 5.0.2 on 10.9 against 10.9 SDK and ran the result under 10.7 with no problem

comment:12 Changed 4 months ago by plorkyeran

Further testing reveals it happens on 10.7.0 but not 10.7.5, so the 10.7 case probably isn't very important.

comment:13 Changed 4 months ago by csomor

could everybody please try with trunk r75364, thanks

comment:14 Changed 4 months ago by joostn

Yes that seems to fix the problem. The above sample now runs on 10.5.8.

Thanks!

comment:15 Changed 4 months ago by SC

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [75378]) backport, fixes #15688

comment:16 Changed 4 months ago by joostn

This patch seems to have caused a new bug. I've opened a new ticket: http://trac.wxwidgets.org/ticket/15771

comment:17 Changed 4 months ago by csomor

  • Resolution fixed deleted
  • Status changed from closed to reopened

I'm probably just too picky with the response values, just comment out the wxFAIL_MSG line, things should just work then, please report ...

Note: See TracTickets for help on using tickets.