I’m trying to trap a runaway Paint event, so I enable “Project” -> “Profile Code”. After running the app, I see the results in a new window. I open one of the entries and double click the caller and I’m taken to the place in the code as expected. HOWEVER, the Profile result window is now gone - POOF!
Since this app is one that exhibits the need for the macOS terminate hack to prevent the app from triggering the macOS Crash Reporter when it exits, would that also relate to the profiler seeing a bad exit? I don’t get Profiler results with the terminate hack enabled or disabled.
It would be helpful to see exactly what code you are calling to terminate your app… but if it’s simply killing the app without letting the app quit on its own, then yes, it could certainly cause profiling to fail. It relies on class destructors to fire for the final wrap-up code to run.
In debug mode, I call “Quit”. In release mode, I call the terminate hack:
[code]//exit the process
If TargetMacOS And Not DebugBuild
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)
Dim appInstance As Integer = sharedApplication(NSClassFromString(“NSApplication”))
terminate(appInstance, appInstance)
Else
Quit
End If[/code]
Added StartProfiling to App.Open and added StopProfiling in App.Close as the first call. Also added a Beep to make sure that the App.Close is what was causing the app to quit.
If you use this declare understand that it effectively behaves like a KILL of the process. Nothing in the app is destroyed properly - the process is simply terminated and no destructors run - not even those in the framework.
[quote=413926:@Tim Jones]Still no profile results.
Added StartProfiling to App.Open and added StopProfiling in App.Close as the first call. Also added a Beep to make sure that the App.Close is what was causing the app to quit.
Get the beep, but no profiling results.[/quote]
You still have to turn profiling on for these methods to do anything otherwise the underlying code they require is not enabled.
I’ve now removed all instances of the terminate hack, and still no profile output. I have one other project that does show the Profiler output and two that don’t. All four profile properly on Linux.
@Jason Parsley : you fix this bug <https://xojo.com/issue/48395> here and then I can remove the declare. My app doesn’t quit at all in 64bit. And this affects the build, too, not only debug.