Skip to content

Stack empty exception #8334

@cdrose

Description

@cdrose

Required Info
Camera Model D415
Firmware Version 05.12.07.100
Operating System & Version Win 10
Platform PC
SDK Version 2.38.1.2223
Language C#
Segment Machine Vision

I am working on a multi-camera multi-threaded application using the C# wrapper and I get sporadic 'Stack empty' exceptions from librealsense. Sometimes on pipeline.WaitForFrames() but more often on depthFrame = fs.DepthFrame.DisposeWith(fs) or colorFrame = fs.ColorFrame.DisposeWith(fs) lines. The exceptions seem to be non terminal in that I can catch them and skip that frame and the application continues to capture frames and perform as expected.

I gather that the ObjectPool is related to how librealsense reuses memory to avoid garbage collection overhead. I also wonder if perhaps the way I am using the library is a bit unusual in that I am capturing frames, extracting several small regions of interest and then packing them back into Frames before running the depth filtering process. Benchmarking it shows a significant speed up over trying to process the full frame for my application but it probably means I am using more objects at any one time than the average realsense application. Could this be related?

The stack trace from Visual Studio looks like this:

   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at System.Collections.Generic.Stack`1.Pop()
   at Intel.RealSense.ObjectPool.Get(Type t, IntPtr ptr)
   at Intel.RealSense.ObjectPool.Get[T](IntPtr ptr)
   at Intel.RealSense.Frame.Create[T](Frame other)
   at Intel.RealSense.Frame.Cast[T]()
   at Intel.RealSense.FrameSet.FirstOrDefault[T](Stream stream, Format format)
   at Intel.RealSense.FrameSet.get_ColorFrame()
   at RealSenseTrial.Orientation.RotationUnit.onFrameReceived(Object sender, FrameEventArgs args)

The realsense logs aren't much help:

 09/02 21:57:12,132 DEBUG [28076] (sync.cpp:526) fps 60 Color 7 8818 1612861032106.993164 
 09/02 21:57:12,132 DEBUG [28076] (sync.cpp:539) (TS: I Depth I Infrared I Infrared I Color )Color 7 8818 1612861032106.993164 fps 60 gap 16.666666 next_expected: 1612861032123.659912
 09/02 21:57:12,132 DEBUG [28076] (sync.cpp:526) fps 60 Color 7 8818 1612861032106.993164 
 09/02 21:57:12,132 DEBUG [28076] (sync.cpp:598) next expected of the missing stream didn't updated yet
 09/02 21:57:12,132 DEBUG [28076] (sync.cpp:343) (TS: I Depth I Infrared I Infrared I Color ) Color 7 8818 1612861032106.993164  Wait for missing stream: 4 next expected 1612861032106.664307
 09/02 21:57:12,132 DEBUG [28076] (frame-archive.h:148) CallbackFinished,Color,8818,DispatchedAt,1612861032132.675781
**Exception thrown: 'System.InvalidOperationException' in System.dll**
 09/02 21:57:12,140 DEBUG [20472] (global_timestamp_reader.cpp:123) librealsense::CLinearCoefficients::calc_value: 3715521.497000 -> 1612861032106.795166 with coefs:0.999895, -11.540764, 3567007.826000, 1612860883620.263184
 09/02 21:57:12,140 DEBUG [20472] (sensor.cpp:348) FrameAccepted,Depth,Counter,8793,Index,0,BackEndTS,1612861032121.000000,SystemTime,1612861032140.320313 ,diff_ts[Sys-BE],19.320313,TS,1612861032106.795166,TS_Domain,Global Time,last_frame_number,8792,last_timestamp,1612861032089.997559
 09/02 21:57:12,140 DEBUG [20472] (archive.cpp:293) CallbackStarted,Depth,8793,DispatchedAt,1612861032140.740723
 09/02 21:57:12,140 DEBUG [20472] (archive.cpp:293) CallbackStarted,Depth,8793,DispatchedAt,1612861032140.771484
 09/02 21:57:12,140 DEBUG [20472] (sync.cpp:147) DISPATCH (TS: )--> Depth 4 8793 1612861032106.795166 `

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions