The problem is there again right now - again only if I copy the application, not if I move it.
I am suspecting that the launch daemon for some reason can't or won't launch the application. I tried to delve into what I presume is the log file for the launch daemon, /var/log/com.apple.xpc.launchd/launchd.log. I would like to hear if the observations here can explain why the application sometimes gets stuck. Thanks again!
First an example of what it looks like when the test application (here called TestApp) actually does get launched (there is a lot more about service stubs being created, but I left that out).
2022-09-29 13:31:07.270877 (gui/739/application.com.ccieurope.TestApp.26282168.26282251) <Notice>: internal event: WILL_SPAWN, code = 0
2022-09-29 13:31:07.270883 (gui/739/application.com.ccieurope.TestApp.26282168.26282251) <Notice>: service state: spawn scheduled
2022-09-29 13:31:07.270884 (gui/739/application.com.ccieurope.TestApp.26282168.26282251) <Notice>: service state: spawning
2022-09-29 13:31:07.270894 <Notice>: Coalition Cache Hit: app<application.com.ccieurope.TestApp.26282168.26282251(739)> [2930]
2022-09-29 13:31:07.270977 (gui/739/application.com.ccieurope.TestApp.26282168.26282251) <Notice>: launching: non-ipc demand
2022-09-29 13:31:07.271506 (gui/739/application.com.ccieurope.TestApp.26282168.26282251 [6799]) <Notice>: xpcproxy spawned with pid 6799
2022-09-29 13:31:07.271518 (gui/739/application.com.ccieurope.TestApp.26282168.26282251 [6799]) <Notice>: internal event: SPAWNED, code = 0
2022-09-29 13:31:07.271519 (gui/739/application.com.ccieurope.TestApp.26282168.26282251 [6799]) <Notice>: service state: xpcproxy
2022-09-29 13:31:07.271539 (gui/739/application.com.ccieurope.TestApp.26282168.26282251 [6799]) <Notice>: internal event: SOURCE_ATTACH, code = 0
2022-09-29 13:31:07.276701 (gui/739/application.com.ccieurope.TestApp.26282168.26282251 [6799]) <Notice>: service state: running
2022-09-29 13:31:07.276705 (gui/739/application.com.ccieurope.TestApp.26282168.26282251 [6799]) <Notice>: internal event: INIT, code = 0
2022-09-29 13:31:07.276706 (gui/739/application.com.ccieurope.TestApp.26282168.26282251 [6799]) <Notice>: job state = running
2022-09-29 13:31:07.276721 (gui/739/application.com.ccieurope.TestApp.26282168.26282251 [6799]) <Notice>: Successfully spawned TestApp[6799] because non-ipc demand
2022-09-29 13:31:07.282872 (pid/6799 [TestApp]) <Notice>: uncorking exec source upfront
2022-09-29 13:31:07.282895 (pid/6799 [TestApp]) <Notice>: created
2022-09-29 13:31:07.283117 (pid/6799 [TestApp]) <Notice>: uncorking domain
2022-09-29 13:31:07.284771 (pid/6799 [TestApp]) <Notice>: Service stub created for com.apple.CMValidateMovieDataReferenceService
2022-09-29 13:31:07.284811 (pid/6799 [TestApp]) <Notice>: Service stub created for com.apple.ColorSyncXPCAgent
2022-09-29 13:31:07.284823 (pid/6799 [TestApp]) <Notice>: Service stub created for com.apple.CoreDisplay.XPCService
2022-09-29 13:31:07.284831 (pid/6799 [TestApp]) <Notice>: Service stub created for com.apple.ImageIOXPCService
2022-09-29 13:31:07.284879 (pid/6799/com.apple.MTLCompilerService) <Notice>: created the implicit endpoint upfront
2022-09-29 13:31:07.284893 (pid/6799/com.apple.MTLCompilerService) <Notice>: draining messages from com.apple.MTLCompilerService
2022-09-29 13:31:07.284901 (pid/6799 [TestApp]) <Notice>: Service stub created for com.apple.PerfPowerTelemetryClientRegistrationService
2022-09-29 13:31:07.284911 (pid/6799 [TestApp]) <Notice>: Service stub created for com.apple.appkit.xpc.ColorPickerImageLoader
2022-09-29 13:31:07.284919 (pid/6799 [TestApp]) <Notice>: Service stub created for com.apple.appkit.xpc.LegacyExternalColorPickerService.arm64
2022-09-29 13:31:07.284926 (pid/6799 [TestApp]) <Notice>: Service stub created for com.apple.appkit.xpc.LegacyExternalColorPickerService.x86_64
2022-09-29 13:31:07.284930 (pid/6799 [TestApp]) <Notice>: Service stub created for com.apple.appkit.xpc.VersionsUIHelper
2022-09-29 13:31:07.284935 (pid/6799 [TestApp]) <Notice>: Service stub created for com.apple.appkit.xpc.WindowSharingControlViewService
2022-09-29 13:31:07.284939 (pid/6799 [TestApp]) <Notice>: Service stub created for com.apple.appkit.xpc.documentPopoverViewService
2022-09-29 13:31:07.284945 (pid/6799 [TestApp]) <Notice>: Service stub created for com.apple.appkit.xpc.openAndSavePanelService
2022-09-29 13:31:07.284950 (pid/6799 [TestApp]) <Notice>: Service stub created for com.apple.appkit.xpc.sandboxedServiceRunner
Now, the excerpt below is what I get when the application gets stuck. It seems that it never gets to the part where the service stubs are created:
2022-09-29 13:23:59.437276 (gui/739/application.com.ccieurope.TestApp.26282648.26282653) <Notice>: service state: spawn scheduled
2022-09-29 13:23:59.437277 (gui/739/application.com.ccieurope.TestApp.26282648.26282653) <Notice>: service state: spawning
2022-09-29 13:23:59.437287 <Notice>: Coalition Cache Hit: app<application.com.ccieurope.TestApp.26282648.26282653(739)> [2964]
2022-09-29 13:23:59.437353 (gui/739/application.com.ccieurope.TestApp.26282648.26282653) <Notice>: launching: non-ipc demand
2022-09-29 13:23:59.437785 (gui/739/application.com.ccieurope.TestApp.26282648.26282653 [6685]) <Notice>: xpcproxy spawned with pid 6685
2022-09-29 13:23:59.437798 (gui/739/application.com.ccieurope.TestApp.26282648.26282653 [6685]) <Notice>: internal event: SPAWNED, code = 0
2022-09-29 13:23:59.437799 (gui/739/application.com.ccieurope.TestApp.26282648.26282653 [6685]) <Notice>: service state: xpcproxy
2022-09-29 13:23:59.437812 (gui/739/application.com.ccieurope.TestApp.26282648.26282653 [6685]) <Notice>: internal event: SOURCE_ATTACH, code = 0
2022-09-29 13:23:59.442645 (gui/739/application.com.ccieurope.TestApp.26282648.26282653 [6685]) <Notice>: service state: running
2022-09-29 13:23:59.442652 (gui/739/application.com.ccieurope.TestApp.26282648.26282653 [6685]) <Notice>: internal event: INIT, code = 0
2022-09-29 13:23:59.442654 (gui/739/application.com.ccieurope.TestApp.26282648.26282653 [6685]) <Notice>: job state = running
2022-09-29 13:23:59.442665 (gui/739/application.com.ccieurope.TestApp.26282648.26282653 [6685]) <Notice>: Successfully spawned TestApp[6685] because non-ipc demand