Crash caused by getFocus() (I think)

Hi, wonder if anyone has any ideas about this.

I have several plugins that sometimes get into this loop:

0   libsystem_pthread.dylib       	       0x1bee970cc ___chkstk_darwin + 60
1   SkyLight                      	       0x1c40541b4 _CGSSetWindowListTags + 44
2   SkyLight                      	       0x1c40eb0c0 SLSSetWindowTags + 152
3   AppKit                        	       0x1c2570158 -[NSCGSWindow setTags:mask:] + 160
4   AppKit                        	       0x1c1c6f000 -[NSWindow becomeKeyWindow] + 576
5   MIDISynth-Peak                	       0x118110fa4 juce::JuceNSWindowClass::JuceNSWindowClass()::'lambda1'(objc_object*, objc_selector*)::__invoke(objc_object*, objc_selector*) + 60
6   AppKit                        	       0x1c1c034c0 -[NSWindow _changeKeyAndMainLimitedOK:] + 1044
7   MIDISynth-Peak                	       0x1181202a0 juce::NSViewComponentPeer::grabFocus() + 36
8   MIDISynth-Peak                	       0x118111004 juce::JuceNSWindowClass::JuceNSWindowClass()::'lambda1'(objc_object*, objc_selector*)::__invoke(objc_object*, objc_selector*) + 156
9   AppKit                        	       0x1c1c034c0 -[NSWindow _changeKeyAndMainLimitedOK:] + 1044
10  MIDISynth-Peak                	       0x1181202a0 juce::NSViewComponentPeer::grabFocus() + 36
11  MIDISynth-Peak                	       0x118111004 juce::JuceNSWindowClass::JuceNSWindowClass()::'lambda1'(objc_object*, objc_selector*)::__invoke(objc_object*, objc_selector*) + 156
12  AppKit                        	       0x1c1c034c0 -[NSWindow _changeKeyAndMainLimitedOK:] + 1044
13  MIDISynth-Peak                	       0x1181202a0 juce::NSViewComponentPeer::grabFocus() + 36
14  MIDISynth-Peak                	       0x118111004 juce::JuceNSWindowClass::JuceNSWindowClass()::'lambda1'(objc_object*, objc_selector*)::__invoke(objc_object*, objc_selector*) + 156
15  AppKit                        	       0x1c1c034c0 -[NSWindow _changeKeyAndMainLimitedOK:] + 1044
16  MIDISynth-Peak                	       0x1181202a0 juce::NSViewComponentPeer::grabFocus() + 36
17  MIDISynth-Peak                	       0x118111004 juce::JuceNSWindowClass::JuceNSWindowClass()::'lambda1'(objc_object*, objc_selector*)::__invoke(objc_object*, objc_selector*) + 156

This only happens in an AU running natively and is not always consistent. Got 3 separate projects this happens with. If I switch to rosetta then the problem disappears. 1 project this happens every now and then, other projects can get it to happen every time.

Before the crash, the loop incolving grabFocus() runs about 200 or so times - not sure if that’s anything to do with it?

Can’t reproduce in the demo audio plugin, so clearly something I’m doing wrong, but trying to think of something that would cause to get stuck in this loop.

Thx

still not really getting anywhere with this.

any of the juce team got any insights?

thx

Sounds superficially similar to this issue:

It seems to be caused by displaying secondary windows in an out-of-process-hosted plugin on macOS. We haven’t managed to dig into the problem yet.

1 Like

thx for the pointer - does indeed seem to be similar/same issue, although I don’t launch any windows other than the main window that is created for the plugin.

Also, FYI, these plugins definitely used to work native silicon, so assume something had changed somewhere.

thx

Is this related to any specific user interaction with the window, and is it restricted to certain Juce versions (does it affect builds you may have on older verisons of Juce?)

1 Like

No, no chance for user interaction, plugin stops as soon as it’s loaded.

Previous releases of my plugins no longer work either (which did work in the past).

Can you give us a minimal code-example which demonstrates the problem?

as it doesn’t happen with the demo plugin, I don’t think so. If I get the time to take apart one of my plugins until it stops happening then I will, but not sure if I’ll have the capacity to do this in the near future.

thx

What was the working configuration, and what’s changed since then? If your plugins stopped working without making any code changes, then it sounds like the problem might have been introduced in a host or macOS update.

Without knowing the problematic host, platform, and macOS versions, and without a minimal test case, this is going to be very difficult to track down.

1 Like

I can’t remember what was working - I was only made aware of this issue recently so I would guess a recent MacOS or Logic update as you summise. It would mostly likely have been september when I released an update as I would have tested then. So, whatever the current version of MacOs Monterey and Logic was at that point.

Maybe you could ask on the other thread that you posted for examples - someone on that thread might have found a simple way of reproducing?

Are you doing and code that invalidates paint within paint? Eg settings a label from paint, etc?

Have you tried sticking a breakpoint or some logging inside Component::addToDesktop? Given the similarity with the other issue, it would be a good idea to categorically confirm that no additional windows are being created.

1 Like

i would hope not! :slight_smile:

i can do that when i get to my other machine - don’t want to turn SIP off on this one.

Hi, confirmed that this is only called once, and also that when running under the debugger, the plugin loads fine.

Please check out this commit and check whether it resolves the issue:

1 Like

it does - thanks!