JUCE Assertion failure in juce_LookAndFeel (6.1.4->6.1.6)

Hi!

I am recently updating from 6.1.4 to 6.1.6 and get this error when running
JUCE Assertion failure in juce_LookAndFeel.cpp:85

Really have no clue what to do here as it doesn’t point to any application specific code in the debug stack

Could you please provide the stack? If you type bt into the debug console when you’re on the assertion that would be helpful.

If you continue past the assertion what GUI elements are now rendered in black?

here is the debug trace! didn’t know you could do that from the command line so thanks for the tip!

After continuing past the assertion once it renders to our initial screen but the assertions never stop happening. After continuing past the assertion like 20 or so times the UI just disappears.

If it helps, our project is open source and you could check out the code out at https://github.com/Princeton-CDH/bitKlavier. Our most up to date code is on develop but I imagine this assert bug will happen on the main branch as well.

  * frame #0: 0x000000010578a08c bitKlavier`juce::LookAndFeel::findColour(this=0x000000015b6761d8, colourID=16797704) const at juce_LookAndFeel.cpp:85:5
    frame #1: 0x0000000105789e14 bitKlavier`juce::Component::findColour(this=0x000000014b6725a0, colourID=16797704, inheritFromParent=false) const at juce_Component.cpp:2218:29
    frame #2: 0x0000000105292e6c bitKlavier`BKKeymapKeyboardComponent::paint(this=0x000000014b6725a0, g=0x000000016b1a74a8) at BKKeyboard.cpp:428:29
    frame #3: 0x0000000105789154 bitKlavier`juce::Component::paintComponentAndChildren(this=0x000000014b6725a0, g=0x000000016b1a74a8) at juce_Component.cpp:2009:13
    frame #4: 0x000000010578902c bitKlavier`juce::Component::paintEntireComponent(this=0x000000014b6725a0, g=0x000000016b1a74a8, ignoreAlphaLevel=false) at juce_Component.cpp:2106:9
    frame #5: 0x0000000105788ca8 bitKlavier`juce::Component::paintWithinParentContext(this=0x000000014b6725a0, g=0x000000016b1a74a8) at juce_Component.cpp:1993:9
    frame #6: 0x0000000105789448 bitKlavier`juce::Component::paintComponentAndChildren(this=0x0000000120030390, g=0x000000016b1a74a8) at juce_Component.cpp:2051:31
    frame #7: 0x000000010578902c bitKlavier`juce::Component::paintEntireComponent(this=0x0000000120030390, g=0x000000016b1a74a8, ignoreAlphaLevel=false) at juce_Component.cpp:2106:9
    frame #8: 0x0000000105788ca8 bitKlavier`juce::Component::paintWithinParentContext(this=0x0000000120030390, g=0x000000016b1a74a8) at juce_Component.cpp:1993:9
    frame #9: 0x0000000105789448 bitKlavier`juce::Component::paintComponentAndChildren(this=0x0000000120030270, g=0x000000016b1a74a8) at juce_Component.cpp:2051:31
    frame #10: 0x000000010578902c bitKlavier`juce::Component::paintEntireComponent(this=0x0000000120030270, g=0x000000016b1a74a8, ignoreAlphaLevel=false) at juce_Component.cpp:2106:9
    frame #11: 0x0000000105788ca8 bitKlavier`juce::Component::paintWithinParentContext(this=0x0000000120030270, g=0x000000016b1a74a8) at juce_Component.cpp:1993:9
    frame #12: 0x0000000105789448 bitKlavier`juce::Component::paintComponentAndChildren(this=0x0000000120030170, g=0x000000016b1a74a8) at juce_Component.cpp:2051:31
    frame #13: 0x000000010578902c bitKlavier`juce::Component::paintEntireComponent(this=0x0000000120030170, g=0x000000016b1a74a8, ignoreAlphaLevel=false) at juce_Component.cpp:2106:9
    frame #14: 0x0000000105788ca8 bitKlavier`juce::Component::paintWithinParentContext(this=0x0000000120030170, g=0x000000016b1a74a8) at juce_Component.cpp:1993:9
    frame #15: 0x0000000105789448 bitKlavier`juce::Component::paintComponentAndChildren(this=0x0000000120030000, g=0x000000016b1a74a8) at juce_Component.cpp:2051:31
    frame #16: 0x000000010578902c bitKlavier`juce::Component::paintEntireComponent(this=0x0000000120030000, g=0x000000016b1a74a8, ignoreAlphaLevel=false) at juce_Component.cpp:2106:9
    frame #17: 0x0000000105788ca8 bitKlavier`juce::Component::paintWithinParentContext(this=0x0000000120030000, g=0x000000016b1a74a8) at juce_Component.cpp:1993:9
    frame #18: 0x0000000105789448 bitKlavier`juce::Component::paintComponentAndChildren(this=0x000000014c18f800, g=0x000000016b1a74a8) at juce_Component.cpp:2051:31
    frame #19: 0x000000010578902c bitKlavier`juce::Component::paintEntireComponent(this=0x000000014c18f800, g=0x000000016b1a74a8, ignoreAlphaLevel=false) at juce_Component.cpp:2106:9
    frame #20: 0x0000000105788ca8 bitKlavier`juce::Component::paintWithinParentContext(this=0x000000014c18f800, g=0x000000016b1a74a8) at juce_Component.cpp:1993:9
    frame #21: 0x0000000105789448 bitKlavier`juce::Component::paintComponentAndChildren(this=0x000000015b907e00, g=0x000000016b1a74a8) at juce_Component.cpp:2051:31
    frame #22: 0x000000010578902c bitKlavier`juce::Component::paintEntireComponent(this=0x000000015b907e00, g=0x000000016b1a74a8, ignoreAlphaLevel=true) at juce_Component.cpp:2106:9
    frame #23: 0x000000010583e1dc bitKlavier`juce::ComponentPeer::handlePaint(this=0x0000600002f70c40, contextToPaintTo=0x000000016b1a7670) at juce_ComponentPeer.cpp:132:19
    frame #24: 0x00000001058f5308 bitKlavier`juce::NSViewComponentPeer::drawRectWithContext(this=0x0000600002f70c40, cg=0x0000600002336400, r=(origin = (x = 0, y = 0), size = (width = 935, height = 728)), displayScale=1) at juce_mac_NSViewComponentPeer.mm:978:13
    frame #25: 0x00000001058f51b8 bitKlavier`juce::NSViewComponentPeer::drawRect(this=0x0000600002f70c40, r=(origin = (x = 0, y = 0), size = (width = 935, height = 728))) at juce_mac_NSViewComponentPeer.mm:966:9
    frame #26: 0x00000001058f5070 bitKlavier`void juce::JuceNSViewClass::callOnOwner<void (juce::NSViewComponentPeer::*)(CGRect), CGRect&>(self=0x000000015b67efa0, func=0x000000016b1a7890, args=(origin = (x = 0, y = 0), size = (width = 935, height = 728)))(CGRect), CGRect&) at juce_mac_NSViewComponentPeer.mm:2308:13
    frame #27: 0x00000001058f16c8 bitKlavier`juce::JuceNSViewClass::drawRect(self=0x000000015b67efa0, (null)="drawRect:", r=(origin = (x = 0, y = 0), size = (width = 935, height = 728))) at juce_mac_NSViewComponentPeer.mm:1977:66
    frame #28: 0x0000000186083584 AppKit`_NSViewDrawRect + 148
    frame #29: 0x00000001867b9af0 AppKit`-[NSView _recursive:displayRectIgnoringOpacity:inContext:stopAtLayerBackedViews:] + 1312
    frame #30: 0x0000000186082d08 AppKit`-[NSView(NSLayerKitGlue) _drawViewBackingLayer:inContext:drawingHandler:] + 676
    frame #31: 0x00000001860829a8 AppKit`-[NSView(NSLayerKitGlue) drawLayer:inContext:] + 320
    frame #32: 0x000000018a2388f8 QuartzCore`CABackingStoreUpdate_ + 496
    frame #33: 0x000000018a297778 QuartzCore`invocation function for block in CA::Layer::display_() + 64
    frame #34: 0x000000018a237b68 QuartzCore`-[CALayer _display] + 1768
    frame #35: 0x0000000186082778 AppKit`-[_NSBackingLayer display] + 372
    frame #36: 0x0000000185ffb838 AppKit`-[_NSViewBackingLayer display] + 648
    frame #37: 0x000000018a236c70 QuartzCore`CA::Layer::display_if_needed(CA::Transaction*) + 776
    frame #38: 0x000000018a37939c QuartzCore`CA::Context::commit_transaction(CA::Transaction*, double, double*) + 528
    frame #39: 0x000000018a218ff0 QuartzCore`CA::Transaction::commit() + 680
    frame #40: 0x000000018609454c AppKit`__62+[CATransaction(NSCATransaction) NS_setFlushesWithDisplayLink]_block_invoke + 304
    frame #41: 0x00000001867f64ac AppKit`___NSRunLoopObserverCreateWithHandler_block_invoke + 64
    frame #42: 0x00000001833d3e4c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36
    frame #43: 0x00000001833d3c98 CoreFoundation`__CFRunLoopDoObservers + 572
    frame #44: 0x00000001833d31d0 CoreFoundation`__CFRunLoopRun + 764
    frame #45: 0x00000001833d2734 CoreFoundation`CFRunLoopRunSpecific + 600
    frame #46: 0x000000018bf6af68 HIToolbox`RunCurrentEventLoopInMode + 292
    frame #47: 0x000000018bf6abf4 HIToolbox`ReceiveNextEventCommon + 320
    frame #48: 0x000000018bf6aa9c HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 72
    frame #49: 0x0000000185f29000 AppKit`_DPSNextEvent + 844
    frame #50: 0x0000000185f278a4 AppKit`-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1332
    frame #51: 0x0000000185f199b4 AppKit`-[NSApplication run] + 596
    frame #52: 0x000000010565c688 bitKlavier`juce::MessageManager::runDispatchLoop(this=0x00006000018a2cd0) at juce_mac_MessageManager.mm:359:13
    frame #53: 0x000000010565c598 bitKlavier`juce::JUCEApplicationBase::main() at juce_ApplicationBase.cpp:262:40
    frame #54: 0x000000010565c41c bitKlavier`juce::JUCEApplicationBase::main(argc=3, argv=0x000000016b1ab450) at juce_ApplicationBase.cpp:240:16
    frame #55: 0x0000000104c57f00 bitKlavier`main(argc=3, argv=0x000000016b1ab450) at juce_audio_plugin_client_Standalone.cpp:47:1
    frame #56: 0x00000001089a90f4 dyld`start + 520```

I actually hit this same issue on a keyboard component I had in an app – it was essentially a copy paste of the JUCE keyboard component with some modifications which couldn’t be overridden directly from the class.

I ended up having to just redo the process and use the correct new bases classes from JUCE – I believe the issue stemmed with something changing in the color definition of the L&F for the keyboard.

My changes were fairly trivial so I didn’t even look into what changed - but you might need to redo your custom keyboard to pull from the new generic keyboard bases preset in JUCE now – my guess would be in your custom keyboard you have:

    enum ColourIds
    {
        whiteNoteColourId               = 0x1005000,
        blackNoteColourId               = 0x1005001,
        keySeparatorLineColourId        = 0x1005002,
        mouseOverKeyOverlayColourId     = 0x1005003,  /**< This colour will be overlaid on the normal note colour. */
        keyDownOverlayColourId          = 0x1005004,  /**< This colour will be overlaid on the normal note colour. */
        textLabelColourId               = 0x1005005,
        upDownButtonBackgroundColourId  = 0x1005006,
        upDownButtonArrowColourId       = 0x1005007,
        shadowColourId                  = 0x1005008
    };

But when you call these colors – it’s probably finding them via the original base class which no longer exists, I don’t think these are actually registered with the look and feel how you have this customized.

Or you can just modify your class to not use this find color calls

1 Like

okay, I see what you’re saying as I do have that line in the keyboard class. I am unsure what the actual change should be though? Are you saying that the IDs just need to change?

If I removed find color what would I then replace it with?

remove find color and replace it with just a color that you want –

When you say findColour – it’s going to the color defines and then looking up that color for the look and feel – JUCE is managing all of that for you:

        0x1004000, /*KeyboardComponentBase::upDownButtonBackgroundColourId*/  0xffd3d3d3,

so when you say find color with these IDs from this class you have, they don’t actually exist cause you never actually registered them with the look and feel yourself.

I.E. it was just a fluke it worked in the first place.

1 Like

I see now. Any idea how I could figure out what the actual colors for things like the keySeparatorLineColourId were?

Thanks so much for the help!