AsyncUpdater crash when adding childpanel
-
I'm running into an issue that I can't pinpoint. I'm using a factory method to add child panels to other child panels. Everything works perfectly in HISE, but compiled plug-ins crash.
When I debug, I get a breakpoint at:AsyncUpdater::~AsyncUpdater() { // You're deleting this object with a background thread while there's an update // pending on the main event thread - that's pretty dodgy threading, as the callback could // happen after this destructor has finished. You should either use a MessageManagerLock while // deleting this object, or find some other way to avoid such a race condition. jassert ((! isUpdatePending()) || MessageManager::getInstanceWithoutCreating() == nullptr || MessageManager::getInstanceWithoutCreating()->currentThreadHasLockedMessageManager()); activeMessage->shouldDeliver.set (0); }
It is triggered by the ScriptPanel:
ScriptingApi::Content::ScriptPanel::~ScriptPanel() { if (parentPanel != nullptr) parentPanel->sendSubComponentChangeMessage(this, false, sendNotificationAsync); stopTimer(); timerRoutine.clear(); mouseRoutine.clear(); loadRoutine.clear(); paintRoutine = var(); loadedImages.clear(); graphics = nullptr; } ScriptingApi::Content::ScriptComponent::~ScriptComponent() { if (linkedComponent != nullptr) linkedComponent->removeLinkedTarget(this); if (currentAutomationData != nullptr) currentAutomationData->asyncListeners.removeListener(*this); }
Commenting out the creation of these additional child panels will make things better.... but minimal examples for adding child panels to other child panels works as expected.
I'm not sure where to look next. -
You should either use a MessageManagerLock while deleting this object, or find some other way to avoid such a race condition.
After looking again, I noticed that the error occurs when something is deleted.
The first line of my factory script has:for (child in myAwesomePanel.getChildPanelList()) { child.removeFromParent(); }
I'm using this to remove any existing panels from my main panel before I repopulate.
Commenting this out also solves the issue... but not ideal.Adding a conditional statement to only remove child panels if they exist appears to work well.
if(myAwesomePanel.getChildPanelList().length > 0) { for (child in myAwesomePanel.getChildPanelList()) { child.removeFromParent(); } }
Are there any adverse affect to doing this?
-
I take it back... still crashing.
-
@Dan-Korneff said in AsyncUpdater crash when adding childpanel:
but minimal examples for adding child panels to other child panels works as expected.
I'm not sure where to look next.Brute force approach. Make a duplicate of your project. In that project start deleting stuff (or commenting it out) bit by bit until the crash no longer occurs. That should help you narrow down exactly which bit of your project is causing the crash.
-
@d-healey I've been doing that all day :(
It seems to be triggered by a few different things, so I guess I'm just waiting find that magical combination.
This app downloads images and draws them into panels, along with other items. It seems that the crash happens when those images are being downloaded.
Back to investigating. -
It seems that the crash happens when those images are being downloaded.
Remove the downloading stuff and hardcode the image paths and see if it still happens.
-
@d-healey If the images exits, NO crash
-
@Christoph-Hart when I open the project in Visual Studio, I get a bunch of errors off the bat.
Severity Code Description Project File Line Suppression State Error (active) E0020 identifier "activeMessage" is undefined My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 90 Error (active) E0276 name followed by '::' must be a class or namespace name My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 26 Error (active) E0262 not a class or struct name My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 26 Error (active) E0260 explicit type is missing ('int' assumed) My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 29 Error (active) E0020 identifier "AsyncUpdater" is undefined My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 29 Error (active) E0065 expected a ';' My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 29 Error (active) E0864 Atomic is not a template My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 38 Error (active) E0260 explicit type is missing ('int' assumed) My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 40 Error (active) E0757 function "juce::<error>::AsyncUpdaterMessage" is not a type name My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 40 Error (active) E0065 expected a ';' My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 41 Error (active) E0276 name followed by '::' must be a class or namespace name My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 44 Error (active) E0020 identifier "activeMessage" is undefined My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 46 Error (active) E0079 expected a type specifier My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 46 Error (active) E0258 'this' may only be used inside a nonstatic member function My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 46 Error (active) E0276 name followed by '::' must be a class or namespace name My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 49 Error (active) E0020 identifier "jassert" is undefined My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 55 Error (active) E0020 identifier "isUpdatePending" is undefined My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 55 Error (active) E0276 name followed by '::' must be a class or namespace name My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 56 Error (active) E0276 name followed by '::' must be a class or namespace name My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 57 Error (active) E0020 identifier "activeMessage" is undefined My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 59 Error (active) E0276 name followed by '::' must be a class or namespace name My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 62 Error (active) E0020 identifier "JUCE_ASSERT_MESSAGE_MANAGER_EXISTS" is undefined My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 66 Error (active) E0065 expected a ';' My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 68 Error (active) E0276 name followed by '::' must be a class or namespace name My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 74 Error (active) E0020 identifier "activeMessage" is undefined My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 76 Error (active) E0276 name followed by '::' must be a class or namespace name My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 79 Error (active) E0020 identifier "JUCE_ASSERT_MESSAGE_MANAGER_IS_LOCKED" is undefined My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 82 Error (active) E0065 expected a ';' My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 84 Error (active) E0276 name followed by '::' must be a class or namespace name My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 88 Error (active) E1670 a type qualifier is not allowed on a nonmember function My Test Plugin_SharedCode C:\Users\Dan\Documents\GitHub\HISE\JUCE\modules\juce_events\broadcasters\juce_AsyncUpdater.cpp 88
Am I doing something silly? or is this something else.