WTF? Application main window suddenly just won't show up

I’ve been having a serious intermittent WTF in my Juce application for months, but now it’s permanent and I’m completely baffled.

The symptom is that I run my application, everything seems absolutely fine… and yet my main window does not appear. I have of course tried things like rebuilding from scratch, without effect.

What’s particularly baffling is that I’ve gone back to known good branches in my code!, checkpoints that were tested by others even, and rebuilt from scratch - and yet now I get the same bad behaviour on those older branches when I rebuild from scratch!

I haven’t installed any new software, or changed my library paths, and the whole thing is statically linked anyway.

Running this in the debugger or pausing the threads gives me no information at all - everything looks perfectly OK. The code eventually ends up in MessageManager::runDispatchLoop() and stays in [NSApp run]; which is completely as accepted.

I can see my menus, I can see the app running, I can see my console which has nothing abnormal on it. Everything’s fine - except the main window simply doesn’t show up. It’s a one-window app so there’s no way to close that window, nor any way to open another one.

I’ve been stuck on this for a day now and I’m completely out of ideas.

Even stranger, I just tried to run a previously saved binary, one that worked fine - and IT displays the same issue!

But I’ve rebooted my machine, and it seems to run everything else perfectly OK. What could be happening?!

I’ve looked through my debug version in great detail. I’ve checked every thread, there appear to be no deadlocks or unexpected waits. This application worked fine 24 hours ago. That binary worked fine for me and for other people. I can’t find the slightest symptom of anything being wrong - except that the window doesn’t appear.

EDIT: GOT IT! Sort of, but at least I know the issue.

For some unknown reason, the window was being set to be height and width 0. Conceivably this was because I had deleted my prefs (but that works fine now I try it again).

I have minimum and maximum dimensions set for that window, so it shouldn’t be able to be resized so small - but it was.

I’m rather interested now in ignoring this, now I have a mediocre workaround, but if anyone’s interested I could look into this further.

OK, I think I’ve figured out the issue completely, and I think in fact I’ve identified a Juce bug.

I create a ResizeableWindow, call setResizeLimits(600, 440, 8192, 8192); and then call setBoundsConstrained(Rectangle(10, 10, 0, 0));

This leads to this code:void ResizableWindow::setBoundsConstrained (const Rectangle<int>& newBounds) { if (constrainer != nullptr) constrainer->setBoundsForComponent (this, newBounds, false, false, false, false); else setBounds (newBounds); } but unfortunately all those “false” parameters mean that neither x, y, width or height are in fact constrained by setResizeLimits in this call.

I don’t see any reason why those values shouldn’t be true, true, true, true. It might be a tiny bit more consumptive in the case where you haven’t actually moved the window, but this is a tiny price to pay.

Hi Tom! Ok, interesting… I think you’re right that it should just be “true, true, true, true”, but am always tentative when the bounds constraining code is involved, because it’s there are so many subtle edge-cases that can arise. But thanks, I’ll have a hard look at it and figure something out…

ah… actually, just setting it to true, true, true, true won’t work, because it’ll incorrectly limit the position of the window as well as its size. I think it needs the logic to be tweaked slightly in ComponentBoundsConstrainer::checkBounds():

[code] if (isStretchingLeft)
bounds.setLeft (jlimit (old.getRight() - maxW, old.getRight() - minW, bounds.getX()));
bounds.setWidth (jlimit (minW, maxW, bounds.getWidth()));

if (isStretchingTop)
    bounds.setTop (jlimit (old.getBottom() - maxH, old.getBottom() - minH, bounds.getY()));
    bounds.setHeight (jlimit (minH, maxH, bounds.getHeight()));


RIght, oops! But that’s why you’re the boss of this. :smiley:

Have a great weekend! (And don’t forget to move your money from your bank to a credit union today…