Showing tooltip in (DirectWrite) plugin causes host crash

Hi Jules,

I encountered a crash when a plugin shows a tooltip while it uses DirectWrite (JUCE_USE_DIRECTWRITE=1). I could reproduce this in VST Plugin Analyser as well as in Reaper.

To do this I implemented tooltips in JuceDemoPlugin:

// PluginEditor.h:
class JuceDemoPluginAudioProcessorEditor : [...]
{
[...]

private:
  TooltipWindow tooltipWindow;
[...]
};

// PluginEditor.cpp:
JuceDemoPluginAudioProcessorEditor::JuceDemoPluginAudioProcessorEditor (JuceDemoPluginAudioProcessor* ownerFilter)
 : [...]
{
  [...]
  setSize (ownerFilter->lastUIWidth,
  ownerFilter->lastUIHeight);

  gainSlider.setTooltip("Tooltip");

  startTimer (50);
}

After the tooltip is shown the Host will crash with an access violation when it is shut down (e.g. Reaper didn’t crash when I removed the plugin). The crash doesn’t occur when the JUCE_USE_DIRECTWRITE macro is set to zero. Before the crash occurs another exception (0x0000087A) is triggered in line 97 ( void release() { if (p != 0) p->Release(); }) of juce_win32_ComSmartPtr.h (the execption is triggered somewhere else, but this is the last listed location in the stack frame).

I’m using today’s juce tip, Visual Studio 2008 Express, Win7 64bit.

Thanks,
Chris

fyi, had a similar issue with DirectWrite, so i deactivated it. (i’m not sure if its still present)
http://www.rawmaterialsoftware.com/viewtopic.php?f=2&t=8379

Thanks, this might be the same issue.
Did you use a TextLayout? I set early returns in TooltipWindow::showFor to check which part of the code might be responsible and the crash occured as soon as LookAndFeel::getTooltipSize() was called which uses a TextLayout.

I also disabled DirectWrite but as it is enabled by default this could be overlooked when starting a new project.

Chris

I have also been running into crashes with directwrite enabled, on a standalone application ( using juce git rev e1fea143b6be8d06b22647653ce964f730676206 from 2012/02/16 , but I don’t think anything relevant has changed since).

The crash happens only if I build with visual c++ 2010 , debugging turned off, and run it on a vista x64 box. The function CustomDirectWriteTextRenderer::DrawGlyphRun ends up being called with an invalid value for baselineOriginY with is set to QNAN ( 0xffffffff in hexadecimal), then currentLine stays at -1 and Textlayout::getLine(-1) is called and the crash soon follows. I spent the afternoon on it but cannot figure if there is a memory corruption in juce, or if it is a DirectWrite bug or whatever.

I’m also going to disable directwrite because I really do not care if my tooltips are drawn with directwrite or not.