Playback exponentially increases CPU

I am running 2018 R1 SDK. We are mostly running Windows 10 Pro OS.

When running 7 cameras live, my CPU sits around 7% (higher than other video integrators, but still totally acceptable)

Each time I open a Playback Dialog, the CPU increases. After closing the Playback dialog, the CPU never decreases.

For both Live and Playback, I set:

EnvironmentManager.Instance.EnvironmentOptions[“UseActiveX”] = “No”;

When I close the Playback window I run:

       if (\_imageViewerControl1 == null) return;

       \_imageViewerControl1.Disconnect();

       \_imageViewerControl1.Close();

       \_imageViewerControl1.Dispose();

       \_imageViewerControl1 = null;

It most definitely seems like the Milestone SDK Environment is holding onto some form of memory or process or playback or something.

This is causing major issues for our customer, who is experiencing the same CPU issue. After opening/closing the Playback window a dozen times, the CPU will be at 90+%, and never reduces.

What is causing this? How can it be corrected?

Note: There are no issues at all with Live view. This issue ONLY involves Playback.

Here is my connection code for Playback:

       if (\_playbackControllerFqid == null)

           \_playbackControllerFqid = ClientControl.Instance.GeneratePlaybackController();

       \_imageViewerControl1 = ClientControl.Instance.GenerateImageViewerControl();

       \_imageViewerControl1.Dock = DockStyle.Fill;

       \_imageViewerControl1.PlaybackControllerFQID = \_playbackControllerFqid;

       panel1.Controls.Clear();

       panel1.Controls.Add(\_imageViewerControl1);

       panel1.Width = this.Width - 2;

       panel1.Height = this.Height - 2;

       panel1.BringToFront();

       \_imageViewerControl1.CameraFQID = \_currentItem.FQID;

       \_imageViewerControl1.EnableVisibleLiveIndicator = EnvironmentManager.Instance.Mode == Mode.ClientLive;

       \_imageViewerControl1.EnableMousePtzEmbeddedHandler = false;

       \_imageViewerControl1.MaintainImageAspectRatio = true;

       \_imageViewerControl1.EnableRecordedImageDisplayedEvent = true;

       \_imageViewerControl1.RecordedImageReceivedEvent += \_imageViewerControl1\_RecordedImageReceivedEvent;

       \_imageViewerControl1.EnableVisibleTimeStamp = true;

       \_imageViewerControl1.SetVideoQuality(DvrConnect.ImageQuality);

       \_imageViewerControl1.EnableVisibleHeader = true;

       \_imageViewerControl1.EnableDigitalZoom = false;

       \_imageViewerControl1.Initialize();

       \_imageViewerControl1.Connect();

       \_imageViewerControl1.Selected = true;

       EnvironmentManager.Instance.EnvironmentOptions\["UseActiveX"\] = "No";

       EnvironmentManager.Instance.SendMessage(

           new VideoOS.Platform.Messaging.Message(MessageId.System.ModeChangeCommand, Mode.ClientPlayback),

           \_playbackControllerFqid);

       EnvironmentManager.Instance.SendMessage(new VideoOS.Platform.Messaging.Message(

           MessageId.SmartClient.PlaybackCommand,

           new PlaybackCommandData() { Command = PlaybackData.Goto, DateTime = \_startTime }), \_playbackControllerFqid);

       EnvironmentManager.Instance.SendMessage(new VideoOS.Platform.Messaging.Message(

           MessageId.SmartClient.PlaybackCommand,

           new PlaybackCommandData() { Command = PlaybackData.PlayForward, Speed = 1.0 }), \_playbackControllerFqid);

       this.Show();

I just changed some code, moving the UseActiveX setting into my Connection method, so it is only called once:

       VideoOS.Platform.SDK.Environment.Initialize();

       VideoOS.Platform.SDK.UI.Environment.Initialize();

       VideoOS.Platform.SDK.Export.Environment.Initialize();

       EnvironmentManager.Instance.EnvironmentOptions\[EnvironmentOptions.HardwareDecodingMode\] = "Auto";

       EnvironmentManager.Instance.TraceFunctionCalls = true;

       EnvironmentManager.Instance.EnvironmentOptions\["UseActiveX"\] = "No";

Even after moving the UseActiveX code, the CPU still exponentially increases after using Playback.

Based on other forum posts, I have also tried the following, which don’t help resolve the issue:

  1. Made sure my Intel drivers were up to date.
  2. Changed from .NET 4.5.2 to .NET 4.7

After opening Playback 10-12 times, the fans on my laptop go into overdrive. It is am immediate clue that my CPU is over 90%, which Task Manager confirms.

What is the resolution to this?

You write that this happens each time you close the playback window, so I assume that a new window is created for each iteration? If that is the case the playback controller (referred by the id you store in _playbackControllerFqid) is not reused and therefore needs to be released as it will otherwise keep running, which could explain what you are seeing. So if you are not reusing it please ensure to release the playback controller by using the ClientControl.Instance.ReleasePlaybackController method.

THAT FIXED IT!!!

Also, this method is NOT in the demo code at all. I can’t even imagine why it isn’t in there. For all the other customers who mentioned CPU usage and memory leaks, they should have been told THIS solution.