BigSur Beta Issue - App.Quit

It seems as if apple’s developer forums are open to the public, e.g. https://developer.apple.com/forums/thread/649774

Therefore, are we OK to post Big Sur-related Xojo issues here? [Please delete this if not. ]

Testing my first Xojo app (built with 2019R1.1) on Big Sur (11.0 Beta 20A4299v), I’m seeing something weird with App.Quit not working. Sometimes it works, but somteimes it fails, and it seems like it’s failing only after my app has run a thread and/or possibly when calling App.Quit from a timer callback?

Here’s what I see in console.log when it fails - this is calling from a Timer callback:

App.TimerCallback // this is my app's logging of a timer callback method which calls my DoQuit method
App.DoQuit  // this is my app's logging of a method which calls App.Quit
33: Calling client's completion block now: clientPID=xxxx, actionID=4096  // this is macOS system logging

After that, nothing happens.

Here’s what I see when using the File/Quit menu:

App.CancelClose // this is my app's logging 
App.Close
Sending exit barrier. // this is macOS system logging
Successfully sent barrier.  // this is macOS system logging

Note: not sure exactly what is causing this, but I found a workaround which is to make sure all windows are closed before calling app.quit. This seems to work.

I wonder if this is related to Thomas recent issue of quit on close ?
https://forum.xojo.com/60856-crash-on-window-close-in-64-bit-with-autoquit-true/p1#p493368

I’ve just recently seen this issue myself

how did u make sure all windows are close??

In my case, this app only has 2 possible open windows so it’s easy to close them both.

If you don’t know how many windows are open, you could use the WindowCount and Window(windowNumber) functions to cycle through them. See http://documentation.xojo.com/api/deprecated/window.html_Method and http://documentation.xojo.com/api/deprecated/window.htmlCount

And you are sure that autoquit is false, aren’t you.

Because, as far as I recall, from Cocoa time, with autoquit = TRUE, I had to remove all calls to quit from close handlers.

And I’d add, skipping the default window itself.

for i as integer = windowcount-1 downto 0 if window(i) isa mainWindow then else //close it end if next

Ive installed the beta profile on an external drive, but not getting offered a download/upgrade … odd?

I have been an issue for a long time - I think introduced with Xojo 2019r1. The only 100% working solutions (And I tried everything including the above code) is by adding the following declares in the CancelClose event:

[quote]declare function NSClassFromString lib “Cocoa” ( aClassName as CFStringRef ) as integer
declare function sharedApplication lib “Cocoa” selector “sharedApplication” ( classRef as integer ) as integer
declare sub terminate lib “Cocoa” selector “terminate:” ( appRef as integer, sender as integer )
var appInstance as integer = sharedApplication( NSClassFromString( “NSApplication” ) )
terminate( appInstance, appInstance )
[/quote]

This way your app will never crash.

[quote=493706:@Christoph De Vocht]declare function NSClassFromString lib “Cocoa” ( aClassName as CFStringRef ) as integer
declare function sharedApplication lib “Cocoa” selector “sharedApplication” ( classRef as integer ) as integer
declare sub terminate lib “Cocoa” selector “terminate:” ( appRef as integer, sender as integer )
var appInstance as integer = sharedApplication( NSClassFromString( “NSApplication” ) )
terminate( appInstance, appInstance )[/quote]

i use this code for my mac app too… but i have similar problem on windows app too but only certain form is open and certain button is click.

[quote=493706:@Christoph De Vocht]I have been an issue for a long time - I think introduced with Xojo 2019r1. The only 100% working solutions (And I tried everything including the above code) is by adding the following declares in the CancelClose event:

[/quote]

I use this as the last thing in my App.Close event and it has been working great since 2018. Just tested it on Big Sur and all is well.

this call to terminate will probably make profiling your app in the IDE not work

It does break profiling.

Yes, you need to surround it with #If Not DebugBuild

terminate should not be necessary (the IDE didnt use it last I knew and probably still doesnt)
it can be a bugger to track down what causes it to be necessary in an app
and there have been some really odd cases

We know that its necessary in Window.Close and App.Open; but to use it as a general catch all is right up there with

catch RuntimeException // Ignore it end try

I’d recommend only using it when you know you have to instead.

[quote=493751:@Norman Palardy]terminate should not be necessary (the IDE didnt use it last I knew and probably still doesnt)
it can be a bugger to track down what causes it to be necessary in an app
and there have been some really odd cases[/quote]
If you want to use Window Restoration for the App Sandbox it is (so that the app can reload the documents that were open when it quit).
Because Xojo “winds down” the windows on quit, the OS removes the attached file access, which means it relies on using the Recent Items Menu to retain access alone.

why App.Open??