What is hanging here?

A user said that my app is hanging. I asked him to sample the process in Activity Monitor. But I can’t make out what is causing the hang. Is it really the change in the dock tile?

 + ! : | + 72 DockItem.UpdateNow%%o<DockItem> (in Mail Archiver X) + 44 [0x102de6fcc]
 + ! : | + 72 CocoaDockItemImp::UpdateImage() (in XojoFramework) + 188 [0x107ca0a0c]
 + ! : | + 36 -[NSApplication _setApplicationIconImage:setDockImage:] (in AppKit) + 68 [0x19bfd6f5c]
 + ! : | + ! 36 -[NSApplication _updateIconImageFromOriginal] (in AppKit) + 264 [0x19bfd70e0]
 + ! : | + ! 36 +[NSAppearance _performWithCurrentAppearance:usingBlock:] (in AppKit) + 72 [0x19bdb6238]
 + ! : | + ! 33 __45-[NSApplication _updateIconImageFromOriginal]_block_invoke (in AppKit) + 76 [0x19bfd717c]
 + ! : | + ! : 33 -[NSImage drawAtPoint:fromRect:operation:fraction:] (in AppKit) + 224 [0x19bf55c90]
 + ! : | + ! : 33 -[NSImage drawInRect:fromRect:operation:fraction:respectFlipped:hints:] (in AppKit) + 1312 [0x19bed83c8]
 + ! : | + ! : 33 -[NSImage _usingBestRepresentationForRect:context:hints:body:] (in AppKit) + 148 [0x19bebc0bc]

I have some minor drawing in the dock tile but this is updated only once a second:

Or is this masking something?

Complete log:

2 Échantillon de Mail Archiver X (While working).rtf.zip (108.8 KB)

Looks like some mess based on a modal window + background tasks + plugin calls. Not a Xojo issue. I think that only you with the plugins support can find out.

By the way, not wrong, but fixing this mistype in the plugin may be cosmetically interesting CallDelegeateOnMainThreadBlock(void*)

The code has been working fine for the last 10 years. The typo is in the MBS plugin.

10 years ago we had 32 bit APIs and Carbon too. Things change. Check the problem.

Which problem should I check? There is one background task and the progress window. Unfortunately, for creating PDFs out of Html I need to load the Html into a HtmlViewer which makes a bit of spaghetti code.

This is a starting point.

No more details? Can the user reproduce the hang, what is he doing before? Which Mac? Which system?
May you can send him a version without Dock animation?

There is no mess. The modal window and the background task IS the code.

Good to know, so there’s no problem.

:rofl:

2 Likes

macOS 15.3.2, ARM, the user had the hang a couple of times. Hang is not reproducible. I’m not sure if the dock animation is the reason for the hang or if it masks the real reason.

Hangs are really rare. I had one earlier this year and there it was quite simple to see which function caused the hang.

I think that there’s some kind of deadlock occurring. And it may be related to a modal mode window locking things + background/timer things requesting locks too. All those at API level and I see plugins acting in the mix. I guess MBS can take a look to see if they find a clearer clue because they are 1000x better than me in MacOS internals.

1 Like

This makes much more sense. The CallDelegateOnMainThreadMBS simplifies code so I’m not sure if this is a culprit or not. I can only send something to Christian if I can reproduce the problem.

But I found something. Normally, I use a ShowModalWithin and here I only use a Show so this is something I can test.