Exception SaveToStream

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
MirroZV
Posts: 45
Joined: Wed May 13, 2020 10:41 am

Exception SaveToStream

Post by MirroZV » Fri Aug 19, 2022 11:32 am

Hello,
we use this method to export chart in some pdf report. One of our customer got exception:

Code: Select all

   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.Path.InternalGetTempFileName(Boolean checkHost)
   at Arction.Wpf.SemibindableCharting.LightningChartUltimate.WZC(Int32 A, Int32 C, Int32 F, Int32 H, Boolean I, String J, TargetImageFormat K, Boolean& L, ChartUpdateTypes& M, Boolean& O)
   at Arction.Wpf.SemibindableCharting.LightningChartUltimate.SaveToStream(Stream stream, TargetImageFormat format, BitmapAntialiasOptions antialiasOptions, Int32 width, Int32 height, Boolean AllowScreenCoordinateChanges)
After investigation it looks like, that temp folder is overflowed, when so many temp files are created. Is there a fix? Shouldn't the file be deleted from temp file?

ArctionKestutis
Posts: 555
Joined: Mon Mar 14, 2016 9:22 am

Re: Exception SaveToStream

Post by ArctionKestutis » Fri Aug 19, 2022 1:09 pm

What was the message in the exception?
How many is "so many temp files"?
Is it reproducible problem?

As far as I could see currently we are deleting temporal files after successful operation.
However, you are not using latest version of LightningChart library. I guess, it is something below 10?! If it was problem in the past, the error maybe fixed already - please verify.

MirroZV
Posts: 45
Joined: Wed May 13, 2020 10:41 am

Re: Exception SaveToStream

Post by MirroZV » Mon Aug 22, 2022 5:26 am

This is the complete exception:

Code: Select all

 at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.Path.InternalGetTempFileName(Boolean checkHost)
   at Arction.Wpf.SemibindableCharting.LightningChartUltimate.WZC(Int32 A, Int32 C, Int32 F, Int32 H, Boolean I, String J, TargetImageFormat K, Boolean& L, ChartUpdateTypes& M, Boolean& O)
   at Arction.Wpf.SemibindableCharting.LightningChartUltimate.SaveToStream(Stream stream, TargetImageFormat format, BitmapAntialiasOptions antialiasOptions, Int32 width, Int32 height, Boolean AllowScreenCoordinateChanges)
   at Metrohm.Controls.Chart.ChartControl.SaveToStream(Stream stream, TargetImageFormat format, BitmapAntialiasOptions antialiasOptions, Int32 width, Int32 height)
   at Metrohm.Miami.Domain.ReportingModel.Data.ChartRendering.BackendRenderer.Generate(ChartDescription description)
   at Metrohm.Miami.Domain.ReportingModel.Data.ChartRendering.BackendRenderer.<>c_DisplayClass5_0.<GenerateSvg>b_0()
   at System.Windows.Threading.DispatcherOperation`1.InvokeDelegateCore()
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
— End of stack trace from previous location where exception was thrown —
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Windows.Threading.DispatcherOperation.Wait(TimeSpan timeout)
   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherOperation operation, CancellationToken cancellationToken, TimeSpan timeout)
   at System.Windows.Threading.Dispatcher.Invoke[TResult](Func`1 callback, DispatcherPriority priority, CancellationToken cancellationToken, TimeSpan timeout)
   at System.Windows.Threading.Dispatcher.Invoke[TResult](Func`1 callback)
   at Metrohm.Miami.Domain.ReportingModel.Data.ChartRendering.BackendRenderer.GenerateSvg(ChartDescription description)
   --- End of inner exception stack trace —
---> (Inner Exception #0) System.IO.IOException: The file exists.

   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.Path.InternalGetTempFileName(Boolean checkHost)
   at Arction.Wpf.SemibindableCharting.LightningChartUltimate.WZC(Int32 A, Int32 C, Int32 F, Int32 H, Boolean I, String J, TargetImageFormat K, Boolean& L, ChartUpdateTypes& M, Boolean& O)
   at Arction.Wpf.SemibindableCharting.LightningChartUltimate.SaveToStream(Stream stream, TargetImageFormat format, BitmapAntialiasOptions antialiasOptions, Int32 width, Int32 height, Boolean AllowScreenCoordinateChanges)
   at Metrohm.Controls.Chart.ChartControl.SaveToStream(Stream stream, TargetImageFormat format, BitmapAntialiasOptions antialiasOptions, Int32 width, Int32 height)
   at Metrohm.Miami.Domain.ReportingModel.Data.ChartRendering.BackendRenderer.Generate(ChartDescription description)
   at Metrohm.Miami.Domain.ReportingModel.Data.ChartRendering.BackendRenderer.<>c_DisplayClass5_0.<GenerateSvg>b_0()
   at System.Windows.Threading.DispatcherOperation`1.InvokeDelegateCore()
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
— End of stack trace from previous location where exception was thrown —
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Windows.Threading.DispatcherOperation.Wait(TimeSpan timeout)
   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherOperation operation, CancellationToken cancellationToken, TimeSpan timeout)
   at System.Windows.Threading.Dispatcher.Invoke[TResult](Func`1 callback, DispatcherPriority priority, CancellationToken cancellationToken, TimeSpan timeout)
   at System.Windows.Threading.Dispatcher.Invoke[TResult](Func`1 callback)
   at Metrohm.Miami.Domain.ReportingModel.Data.ChartRendering.BackendRenderer.GenerateSvg(ChartDescription description)<---
And we call SaveToStream:

Code: Select all

public bool SaveToStream(Stream stream, TargetImageFormat format, BitmapAntialiasOptions antialiasOptions, int width, int height)
        {
            Arction.Wpf.SemibindableCharting.TargetImageFormat targetImageFormat = (Arction.Wpf.SemibindableCharting.TargetImageFormat)Enum.Parse(typeof(Arction.Wpf.SemibindableCharting.TargetImageFormat), format.ToString());
            Arction.Wpf.SemibindableCharting.BitmapAntialiasOptions bitmapAntialiasOptions = antialiasOptions == null ? null : new Arction.Wpf.SemibindableCharting.BitmapAntialiasOptions
            {
                ActualPixelWeight = antialiasOptions.ActualPixelWeight,
                ResolutionDivider = antialiasOptions.ResolutionDivider,
                BlurRadius = antialiasOptions.BlurRadius
            };

            return _lightningChart.SaveToStream(stream, targetImageFormat, bitmapAntialiasOptions, width, height);
        }
Last line creates temp file and this file is never deleted.

MirroZV
Posts: 45
Joined: Wed May 13, 2020 10:41 am

Re: Exception SaveToStream

Post by MirroZV » Mon Jun 12, 2023 6:24 am

Hello, we run into same problem again, with older version of LC 8, and with never version of LC (10.4.1), it seems like when document with chart is generated, then there is file created in AppData/Local/Temp, with name temp{FourRandomUpperCaseAplhanumerics}.tmp . These files are never deleted. After large amounts of files generated, there is problem generated more of them, therefore we and up without charts in reports. This can be mitigated by deleting temp files, but it is inconvenient for our customers.

It seems like this issue is not present on all machines. It seems like 10th or never generation intel machines have this problem, but we are not sure.

Do you know about this problem ?

ArctionKestutis
Posts: 555
Joined: Mon Mar 14, 2016 9:22 am

Re: Exception SaveToStream

Post by ArctionKestutis » Mon Jun 12, 2023 2:00 pm

I will make summary of the issue - please confirm if it is correct.

1) You are using LightningChart method SaveToStream() in your application;
2) You set custom size and use SVG format for the exporting of Chart;
3) Application and chart-export work fine at the beginning;
4) At some longer time, application crash with exception - where it seems like TMP folder is filled-up with too many temporal files;
5) version 8 and version 10.4.1 of LightningChart behaves the same way;
6) the Issue is replicated only in some computers;

The last one maybe in particular interesting, as that would indicate likely graphic drivers problem. Intel 11th and 12th Gen. CPU has some problems with DirectX, which we reported for them. By now, the issue we knew should be fixed: user can use latest Intel graphic drivers or workaround described in our web-page. However, it does not look like issue described here is related.

It seems to me that it is most important to identify when and why temporal files are not deleted.
As I noted before, LightningChart should delete temporal files after successful SaveToStream() operation. Method returns True if succeeded, false otherwise. You can use this flag in application to identify, when something is not going right. Maybe you can get so _chart.ChartMessage event as well (subscribe to check) - check what message says.

Do you have any bitmap in your chart: Marker, Annotation or Background with bitmap fill or style? Vector format (and SVG in particular) is not very friendly with those. LightningChart may show some warning, if detect such item in the chart before exporting.

Could you share the test application where this export problem is manifested? You can send the project directly to Support.

MirroZV
Posts: 45
Joined: Wed May 13, 2020 10:41 am

Re: Exception SaveToStream

Post by MirroZV » Tue Oct 10, 2023 1:35 pm

Hello,

sorry for a late reply, but I finally have some more information about this issue:
  • We are still running into these tmp files even with LightningChart 10.5.1.1
  • ChartMessage event is not triggered during SaveToStream
  • SaveToStream is returning true
  • Only some machine are affected
  • Also AMD machines are affected
  • No bitmap in chart
I tried to gather DxDiag from machines across company, and it mostly followed the pattern of notebooks not be affected and desktops has been affected. Almost all intel machines without any graphics card.

Here are three interesting dxdiag reports
DxDiag.zip
DxDiag
(48.78 KiB) Downloaded 166 times
One of them is intel machine with quadro graphicscard, that is generating tmp files and other two are two machines with same AMD processor and AMD graphics card. One of them is generating tmp files and one not. So it seems like it will be something different than faulty graphics driver.

I will try to create Demo app for it.

MirroZV
Posts: 45
Joined: Wed May 13, 2020 10:41 am

Re: Exception SaveToStream

Post by MirroZV » Wed Oct 11, 2023 6:24 am

I have created demo app for this problem, I will send it to support with additional info about computers

Post Reply