Login Page - Create Account

Support Board


Date/Time: Wed, 07 May 2025 00:57:58 +0000



4 Fonts and 5 Sizes hangs Sierra with sc.Graphics.DrawTextAt()

View Count: 283

[2024-11-27 23:16:36]
User719512 - Posts: 310
4 Fonts and 5 Sizes hangs Sierra with sc.Graphics.DrawTextAt()
4 Fonts and 4 Sizes works as expected.

I created a small sample to easily look at some different fonts and sizes. Much to my surprise, this trivial code causes Sierra to hang.

Sometimes you might see one or two clicks or hovers with mouse or keyboard events work, but they might also take minutes to respond. During this time, charts and data will update as seen by the real-time clock, price updates, and file/network updates from Sysintenrals Process Monitor, but you cannot interact with the charts or the Sierra menus.

Attached is an image showing 2 charts.
The first/left one has the clock to see what's updating.
The second/right has a custom study built with the code below.

REPRO and IMPORTANT INFO:
Close all other Chartbooks before running this repro.
Create a new chartbook up with 2 charts like the repro image and SAVE it.
Build/Add the custom study to see (at least on my machine) 4 fonts and 4 sizes working.
(the defaults are 1 and 1 to ensure creation works first time)
SAVE this version of the chartbook.
Edit the study to show 4 fonts and 5 sizes. (other combos might break Sierra as well)
Hit OK to close all the dialogs...
RESULT: Sierra will now be hung and will need to be terminated from Task Manager


Code to repro the issue:


#include "sierrachart.h"

#include <vector>
using namespace std;

SCDLLName("Sierra Font Sample");

namespace ns_zzz_TestSierraFonts
{
static std::vector<SCString> FontNames = {
"Arial"
, "Tahoma"
, "Segoe UI"
, "Consolas"
, "Courier New"
};

static std::vector<int> FontSizes = {
6
,7
,8
,9
,10
,11
,12
};

//
// DrawToChart
//
void DrawToChart(HWND WindowHandle, HDC DeviceContext, SCStudyInterfaceRef sc)
{
const int region_left = sc.StudyRegionLeftCoordinate;
const int region_top = sc.StudyRegionTopCoordinate;

const char* OutputFormatString = "%s size:%d - Showing 4 Fonts and 4 Sizes works. Changing to 5 Sizes will hang Sierra.";

sc.Graphics.SetTextAlign(TA_NOUPDATECP);
SCString output;
int x = region_top + 50;
int y = region_left + 50;

n_ACSIL::s_GraphicsColor backgroundColor;
backgroundColor.SetColorValue(sc.ChartBackgroundColor);

n_ACSIL::s_GraphicsColor textColor;
textColor.Color.RawColor = COLOR_GRAY;
sc.Graphics.SetTextColor(textColor);
sc.Graphics.SetBackgroundMode(TRANSPARENT);

SCInputRef Input_NumFonts = sc.Input[0];
SCInputRef Input_NumSizes = sc.Input[1];

int fontIndex = 0;
int sizeIndex = 0;

for (auto& font : FontNames)
{
n_ACSIL::s_GraphicsFont graphicsFont;
graphicsFont.m_FaceName = font;

sizeIndex = 0;

for (auto& size : FontSizes)
{
output.Format(OutputFormatString, font.GetChars(), size);

graphicsFont.m_Height = size;
sc.Graphics.SetTextFont(graphicsFont);

n_ACSIL::s_GraphicsSize graphicsSize;
sc.Graphics.GetTextSize(output, graphicsSize);

n_ACSIL::s_GraphicsRectangle rect;
rect.Left = x;
rect.Top = y;
rect.Right = x + graphicsSize.Width;
rect.Bottom = y + graphicsSize.Height;

sc.Graphics.FillRectangleWithColor(rect, backgroundColor);
sc.Graphics.DrawTextAt(output, x, y);

//
y += graphicsSize.Height + 4;

++sizeIndex;
if (sizeIndex >= FontSizes.size() || sizeIndex >= Input_NumSizes.GetInt()) break;
}

++fontIndex;
if (fontIndex >= FontNames.size() || fontIndex >= Input_NumFonts.GetInt()) break;
}
}

//
// scsf_zzz_TestSierraFonts
//
SCSFExport scsf_zzz_TestSierraFonts(SCStudyInterfaceRef sc)
{
SCInputRef Input_NumFonts = sc.Input[0];
SCInputRef Input_NumSizes = sc.Input[1];

if (sc.SetDefaults)
{
sc.GraphName = "zzz_TestSierraFonts";
sc.AutoLoop = 0;
sc.DrawZeros = 0;
sc.GraphRegion = 0;
sc.DrawStudyUnderneathMainPriceGraph = 0;
sc.UpdateAlways = 1;

Input_NumFonts.Name = "Num Fonts";
Input_NumFonts.SetInt(1);
Input_NumFonts.SetIntLimits(1, 5);

Input_NumSizes.Name = "Num Sizes";
Input_NumSizes.SetInt(1);
Input_NumSizes.SetIntLimits(1, 7);

return;
}

sc.p_GDIFunction = DrawToChart;

for (int barIndex = sc.UpdateStartIndex; barIndex < sc.ArraySize; barIndex++)
{
// do work...
}
}

} // ns_zzz_TestSierraFonts

imageScreenshot 2024-11-27 150553.png / V - Attached On 2024-11-27 23:10:54 UTC - Size: 171.26 KB - 60 views
[2024-11-28 00:02:43]
Sierra_Chart Engineering - Posts: 19461
This is not something we are willing to allocate time to. Are you using OpenGL? If you are not using OpenGL, this is not a Sierra Chart issue.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2024-11-28 01:06:45]
User719512 - Posts: 310
Yes, using OpenGL.

Did you try to repro the issue on your machines?

Figured depending on where the issue is may or may not determine if hidden issues exist and your priority to investigate further.
[2024-11-29 01:48:33]
Sierra_Chart Engineering - Posts: 19461
No we are not able to reproduce this. Most of the time these issues are just never reproducible.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2024-11-29 10:40:28]
User907968 - Posts: 840
Similar noted here when using ~20 different sizes of the same font, but only when using OpenGL.
Ended up limiting the study to max 10 sizes which, in my case, was an acceptable compromise.

Some observations -
Using max 10 sizes the render function completes in very low to sub-millisecod time range.
Using 20 sizes the same function can take more than 1 second (often much more) to complete, depending on the number of text objects being drawn.

The source of the slowdown was not limited to DrawTextAt, in fact the various text metric functions also seem affected.
If I call GetTextSize before DrawTextAt then, GetTextSize is slow whereas DrawTextAt is not.
If I call GetTextSizeWithFont then both that call and DrawTextAt are slow, same observed with GetTextHeight/DrawTextAt.


Feel free to delete this post if it is unhelpful.
[2024-11-29 19:55:15]
User719512 - Posts: 310
That's great info User907968 as this could be machine dependent based on memory, video card, etc. The fact that this is not just my single machine is useful information in my opinion. Hopefully Sierra will see this and perhaps dig deeper to see if there is some issue in their code that is somehow limiting or affecting this. Have not seen this in the course of other study development, and this use case is probably an outlier, but such code should not behave like this.
[2024-11-29 21:46:04]
Sierra_Chart Engineering - Posts: 19461
We will check on this.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account