frames returned from nveglstreamsrc via EGL stream out of order

Hi DaneLLL, My original test code is c++ source code, and i have changed all filename suffix to .cu, and all code is compiled by nvcc with -arch=sm_62 flag, but the result is still the same as before.

Here is the compile log:

/usr/local/cuda-8.0/bin/nvcc -D_DEBUG -D_GLIB_TEST_OVERFLOW_FALLBACK -std=c++11 -I"/usr/include/gstreamer-1.0" -I"/usr/include/glib-2.0" -I"/usr/lib/aarch64-linux-gnu/glib-2.0/include" -I"/usr/lib/aarch64-linux-gnu/gstreamer-1.0/include" -I"/usr/local/cuda-8.0/include" --machine 64 -arch=sm_62 -c -o eglstreamproducer_cuda.o ../nveglstreamsrctest/eglstreamproducer.cu
../nveglstreamsrctest/eglstreamproducer.cu: In member function 'void EGLStreamProducer::returnFrame()':
../nveglstreamsrctest/eglstreamproducer.cu:210:109: warning: format '%lld' expects argument of type 'long long int', but argument 3 has type 'int64_t {aka long int}' [-Wformat=]
/usr/local/cuda-8.0/bin/nvcc -D_DEBUG -D_GLIB_TEST_OVERFLOW_FALLBACK -std=c++11 -I"/usr/include/gstreamer-1.0" -I"/usr/include/glib-2.0" -I"/usr/lib/aarch64-linux-gnu/glib-2.0/include" -I"/usr/lib/aarch64-linux-gnu/gstreamer-1.0/include" -I"/usr/local/cuda-8.0/include" --machine 64 -arch=sm_62 -c -o main_cuda.o ../nveglstreamsrctest/main.cu
/usr/local/cuda-8.0/bin/nvcc -D_DEBUG -D_GLIB_TEST_OVERFLOW_FALLBACK -std=c++11 -I"/usr/include/gstreamer-1.0" -I"/usr/include/glib-2.0" -I"/usr/lib/aarch64-linux-gnu/glib-2.0/include" -I"/usr/lib/aarch64-linux-gnu/gstreamer-1.0/include" -I"/usr/local/cuda-8.0/include" --machine 64 -arch=sm_62 -c -o EGLAPIAccessors_cuda.o ../nveglstreamsrctest/EGLAPIAccessors.cu
g++  -o nveglstreamsrctest eglstreamproducer_cuda.o main_cuda.o EGLAPIAccessors_cuda.o   -lgstreamer-1.0 -lglib-2.0 -lgobject-2.0 -lEGL -L/usr/local/cuda-8.0/lib64 -lcuda -lcudart -lpthread

Hi SongjianSu,
could share your implementation so that we can reproduce it on r28.1/TX2? you have attach a few source files, could you also share Makefile and steps to reproduce the issue?

Hi DaneLLL, I submit my test case project in the attachment. After unpacking, run make, and ./nveglstreamsrctest to run the test.
nveglstreamsrctest.tar.gz (5 KB)

Hi SonhjianSu,
Please refer to attachment. It implements

present frame 1
present frame 2
wait for frame 1 to return
present frame 3
wait for frame 2 to return
present frame 4
wait for frame 3 to return
...

The log

nvidia@tegra-ubuntu:~/nveglstreamsrctest$ ./nveglstreamsrctest
CUDA producer initializing EGL display.
EGL API: 1.5
CUDA producer initializing EGL stream.
EGL Stream consumer - Mode: FIFO, Length: 4, latency 0.

NvEglStreamSrcInitializeEgl: Load library: libEGL.so
Connect EGL stream to cuda producer.
CUDA producer present frame: 0x5c2600000.
CUDA producer present frame: 0x5c2800000.
Returned frame 0x5c2600000 used time 1 ms.
CUDA producer present frame: 0x5c2a00000.
Returned frame 0x5c2800000 used time 1 ms.
CUDA producer present frame: 0x5c2c00000.
Returned frame 0x5c2a00000 used time 1 ms.
============================
Present a new frame 1. buf=0x5c2600000
Returned frame 0x5c2c00000 used time 1 ms.
Present a new frame 2. buf=0x5c2800000
Returned frame 0x5c2600000 used time 1 ms.
Present a new frame 3. buf=0x5c2a00000
Returned frame 0x5c2800000 used time 10 ms.
Present a new frame 4. buf=0x5c2c00000
Returned frame 0x5c2a00000 used time 10 ms.
Present a new frame 5. buf=0x5c2600000
Returned frame 0x5c2c00000 used time 10 ms.
Present a new frame 6. buf=0x5c2800000
Returned frame 0x5c2600000 used time 10 ms.
Present a new frame 7. buf=0x5c2a00000
Returned frame 0x5c2800000 used time 10 ms.
Present a new frame 8. buf=0x5c2c00000
Returned frame 0x5c2a00000 used time 10 ms.
Present a new frame 9. buf=0x5c2600000
Returned frame 0x5c2c00000 used time 10 ms.
Present a new frame 10. buf=0x5c2800000
Returned frame 0x5c2600000 used time 10 ms.
Present a new frame 11. buf=0x5c2a00000
Returned frame 0x5c2800000 used time 10 ms.
Present a new frame 12. buf=0x5c2c00000
Returned frame 0x5c2a00000 used time 10 ms.
Present a new frame 13. buf=0x5c2600000
Returned frame 0x5c2c00000 used time 10 ms.
Present a new frame 14. buf=0x5c2800000
Returned frame 0x5c2600000 used time 10 ms.
Present a new frame 15. buf=0x5c2a00000
Returned frame 0x5c2800000 used time 9 ms.
Present a new frame 16. buf=0x5c2c00000
Returned frame 0x5c2a00000 used time 10 ms.
Present a new frame 17. buf=0x5c2600000
Returned frame 0x5c2c00000 used time 10 ms.
Present a new frame 18. buf=0x5c2800000
Returned frame 0x5c2600000 used time 9 ms.
Present a new frame 19. buf=0x5c2a00000
Returned frame 0x5c2800000 used time 10 ms.
Present a new frame 20. buf=0x5c2c00000
Returned frame 0x5c2a00000 used time 9 ms.
Present a new frame 21. buf=0x5c2600000
Returned frame 0x5c2c00000 used time 9 ms.
Present a new frame 22. buf=0x5c2800000
Returned frame 0x5c2600000 used time 9 ms.
Present a new frame 23. buf=0x5c2a00000
Returned frame 0x5c2800000 used time 9 ms.
Present a new frame 24. buf=0x5c2c00000
Returned frame 0x5c2a00000 used time 9 ms.
Present a new frame 25. buf=0x5c2600000
Returned frame 0x5c2c00000 used time 9 ms.
Present a new frame 26. buf=0x5c2800000
Returned frame 0x5c2600000 used time 9 ms.
Present a new frame 27. buf=0x5c2a00000
Returned frame 0x5c2800000 used time 9 ms.
Present a new frame 28. buf=0x5c2c00000
Returned frame 0x5c2a00000 used time 9 ms.
Present a new frame 29. buf=0x5c2600000
Returned frame 0x5c2c00000 used time 9 ms.
Present a new frame 30. buf=0x5c2800000
Returned frame 0x5c2600000 used time 9 ms.
Present a new frame 31. buf=0x5c2a00000
Returned frame 0x5c2800000 used time 9 ms.
Present a new frame 32. buf=0x5c2c00000
Returned frame 0x5c2a00000 used time 9 ms.
Present a new frame 33. buf=0x5c2600000
Returned frame 0x5c2c00000 used time 9 ms.
Present a new frame 34. buf=0x5c2800000
Returned frame 0x5c2600000 used time 9 ms.
Present a new frame 35. buf=0x5c2a00000
Returned frame 0x5c2800000 used time 9 ms.
Present a new frame 36. buf=0x5c2c00000
Returned frame 0x5c2a00000 used time 9 ms.
Present a new frame 37. buf=0x5c2600000
Returned frame 0x5c2c00000 used time 9 ms.
Present a new frame 38. buf=0x5c2800000
Returned frame 0x5c2600000 used time 9 ms.
Present a new frame 39. buf=0x5c2a00000
Returned frame 0x5c2800000 used time 9 ms.
Present a new frame 40. buf=0x5c2c00000
Returned frame 0x5c2a00000 used time 9 ms.
Present a new frame 41. buf=0x5c2600000
Returned frame 0x5c2c00000 used time 9 ms.
Present a new frame 42. buf=0x5c2800000
Returned frame 0x5c2600000 used time 9 ms.
Present a new frame 43. buf=0x5c2a00000
Returned frame 0x5c2800000 used time 9 ms.
Present a new frame 44. buf=0x5c2c00000
Returned frame 0x5c2a00000 used time 9 ms.
Present a new frame 45. buf=0x5c2600000
Returned frame 0x5c2c00000 used time 9 ms.
Present a new frame 46. buf=0x5c2800000
Returned frame 0x5c2600000 used time 9 ms.
Present a new frame 47. buf=0x5c2a00000
Returned frame 0x5c2800000 used time 9 ms.
Present a new frame 48. buf=0x5c2c00000
Returned frame 0x5c2a00000 used time 9 ms.
Present a new frame 49. buf=0x5c2600000
Returned frame 0x5c2c00000 used time 9 ms.
Present a new frame 50. buf=0x5c2800000
Returned frame 0x5c2600000 used time 9 ms.
Terminate EGL display.

nveglstreamsrctest_1.zip (7.02 KB)

Hi DaneLLL, is this a convention or a bug? Why can’t I just keep more than 2 buffers in FIFO queue?

From this simple test case, keep 2 buffers in FIFO queue at most often have to waiting for the ‘returned buffer’ a few milliseconds.

Hi SongjianSu,
This is the design. You don’t need to do return_Frame after avery present_Frame. It works like

present frame 1
present frame 2
present frame 3
present frame 4
return frame... get frame 3

When you get frame 3 in return_Frame, it means frame 1, frame 2, and frame 3 are returned.

Hi DaneLLL, under the design that we don’t actually need to do return_Frame after every present_Frame, and the present_Frame will be blocked when EGL stream FIFO is full, I think the following algorithm will be right:

First, alloc buffer pool of size 2 more than the FIFO size, for example, if the FIFO size is 4, we alloc 6 buffers for the pool.
Then, we use and present the buffers in the manner of circular queue, i.e, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, ...

Is this right? and is there a public specification about the CUDA consumer and producer?

Hi SongjianSu,
The fifo mode follows https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_stream_fifo.txt

Hi DaneLLL, I have read this article before, but this is not about CUDA consumer/producer.

Hi SongjianSu,
The CUDA document is at CUDA Driver API :: CUDA Toolkit Documentation

There is a sample at ~/NVIDIA_CUDA-8.0_Samples/3_Imaging/EGLStreams_CUDA_Interop

Hi DaneLLL, thanks for the reply.

The ~/NVIDIA_CUDA-8.0_Samples/3_Imaging/EGLStreams_CUDA_Interop sample i have been read before, it’s too simple, just pass 2 frames from producer to consumer, and no waiting for the returned frame.

However, I found that there is a more complicated sample ~/NVIDIA_CUDA-8.0_Samples/3_Imaging/EGLStream_CUDA_CrossGPU on r28.1, but indeed it waits for the return_Frame on every present_Frame in a dead loop manner. It means we have to wait for the return_Frame on every present_Frame to keep it working correctly.

So now I am very confused, do I need to wait for the return_Frame on every present_Frame or not?

It should work just as I said in #11. You do return_Frame when all frames are presented. If it returns frame 3, it means buffers of frame 1, 2, 3 are returned.

Hi DaneLLL, thanks for the reply.

ISSUE 1:
I have done more experiments, the EGL stream FIFO is 4, and initially present 10 frames to the EGL stream FIFO, then wait for some time, and then examine the returned frames. But no matter how many frames I present initially and how long I wait, only the first 3 frames returned on the first 3 return_Frame calls, and I can’t see the latter frames returned, for example, the 4th, 7th, etc.

nvidia@tegra-ubuntu:~/program/nveglstreamsrctest$ ./nveglstreamsrctest 
CUDA producer initializing EGL display.
EGL API: 1.5
CUDA producer initializing EGL stream.
EGL Stream consumer - Mode: FIFO, Length: 4, latency 0.

NvEglStreamSrcInitializeEgl: Load library: libEGL.so
Connect EGL stream to cuda producer.
CUDA producer present frame: 0x5c2600000 used time 0 ms.
CUDA producer present frame: 0x5c2800000 used time 0 ms.
CUDA producer present frame: 0x5c2a00000 used time 0 ms.
CUDA producer present frame: 0x5c2c00000 used time 0 ms.
CUDA producer present frame: 0x5c2e00000 used time 0 ms.
CUDA producer present frame: 0x5c3000000 used time 0 ms.
CUDA producer present frame: 0x5c3200000 used time 0 ms.
CUDA producer present frame: 0x5c3400000 used time 0 ms.
CUDA producer present frame: 0x5c3600000 used time 0 ms.
CUDA producer present frame: 0x5c3800000 used time 0 ms.
============= wait some time =============
Returned frame 0x5c2600000 used time 0 ms.
Present a new frame 1.
CUDA producer present frame: 0x5c2600000 used time 0 ms.
Returned frame 0x5c2800000 used time 0 ms.
Present a new frame 2.
CUDA producer present frame: 0x5c2800000 used time 0 ms.
Returned frame 0x5c2a00000 used time 0 ms.
Present a new frame 3.
CUDA producer present frame: 0x5c2a00000 used time 0 ms.
Returned frame 0x5c2600000 used time 0 ms.
Present a new frame 4.
CUDA producer present frame: 0x5c2600000 used time 5 ms.
Returned frame 0x5c2800000 used time 0 ms.
Present a new frame 5.
CUDA producer present frame: 0x5c2800000 used time 0 ms.
Returned frame 0x5c2a00000 used time 0 ms.
Present a new frame 6.
CUDA producer present frame: 0x5c2a00000 used time 1 ms.
Returned frame 0x5c2600000 used time 0 ms.
Present a new frame 7.
CUDA producer present frame: 0x5c2600000 used time 0 ms.
Returned frame 0x5c2800000 used time 0 ms.
Present a new frame 8.
CUDA producer present frame: 0x5c2800000 used time 0 ms.
Returned frame 0x5c2a00000 used time 0 ms.
Present a new frame 9.
CUDA producer present frame: 0x5c2a00000 used time 0 ms.
Returned frame 0x5c2600000 used time 0 ms.
Present a new frame 10.
CUDA producer present frame: 0x5c2600000 used time 0 ms.

ISSUE 2:
The test case (see attachment) sometimes return error 999 (CUDA_ERROR_UNKNOWN) on the initially present frames, and then return_Frame always return 702 (CUDA_ERROR_LAUNCH_TIMEOUT).

nvidia@tegra-ubuntu:~/program/nveglstreamsrctest$ ./nveglstreamsrctest 
CUDA producer initializing EGL display.
EGL API: 1.5
CUDA producer initializing EGL stream.
EGL Stream consumer - Mode: FIFO, Length: 4, latency 0.

NvEglStreamSrcInitializeEgl: Load library: libEGL.so
Connect EGL stream to cuda producer.
CUDA producer present frame: 0x5c2600000 used time 0 ms.
CUDA producer present frame: 0x5c2800000 used time 0 ms.
CUDA producer present frame: 0x5c2a00000 used time 0 ms.
CUDA producer present frame: 0x5c2c00000 used time 0 ms.
CUDA producer present frame: 0x5c2e00000 used time 0 ms.
CUDA producer present frame: 0x5c3000000 used time 0 ms.
CUDA producer present frame: 0x5c3200000 used time 0 ms.
CUDA producer present frame: 0x5c3400000 used time 0 ms.
CUDA producer present frame: 0x5c3600000 used time 0 ms.
CUDA producer present frame failed: 999.
============= wait some time =============
Returned frame 0x5c2600000 used time 0 ms.
Present a new frame 1.
CUDA producer present frame: 0x5c2600000 used time 1 ms.
Returned frame 0x5c2800000 used time 0 ms.
Present a new frame 2.
CUDA producer present frame: 0x5c2800000 used time 0 ms.
^C   //<-- "ctrl + c", block on cuEGLStreamProducerReturnFrame, always return CUDA_ERROR_LAUNCH_TIMEOUT
nvidia@tegra-ubuntu:~/program/nveglstreamsrctest$

ISSUE 3:
When I post this thread, I find the out of order issue in my project. To illustrate the issue, i build the test case, but can’t completely reproduce the issue.

The steps is the same as the test case, first present 4 frames to the EGL stream FIFO, and then do return_Frame to get the buffer, and then present_Frame to EGL stream FIFO. Since the first 4 return_Frame calls only return the 1th and 2nd buffers, it should not return the 3th and 4th buffer later any more. But later on at some point, the 3th and 4th buffers return.

Here is the key log, for the whole output log, please refer to the attachment, For clearly, I have replace the 4 different addresses with 1, 2, 3 and 4 respectively.

<../Project/eglframeproducer.cpp, 112>: Return frame 1
<../Project/eglframeproducer.cpp, 112>: Return frame 2
<../Project/eglframeproducer.cpp, 112>: Return frame 1
<../Project/eglframeproducer.cpp, 112>: Return frame 2
<../Project/eglframeproducer.cpp, 112>: Return frame 1
<../Project/eglframeproducer.cpp, 112>: Return frame 2
<../Project/eglframeproducer.cpp, 112>: Return frame 1
<../Project/eglframeproducer.cpp, 112>: Return frame 2
<../Project/eglframeproducer.cpp, 112>: Return frame 1
<../Project/eglframeproducer.cpp, 112>: Return frame 2
...
some time later
<../Project/eglframeproducer.cpp, 112>: Return frame 1
<../Project/eglframeproducer.cpp, 112>: Return frame 2
<../Project/eglframeproducer.cpp, 112>: Return frame 3
<../Project/eglframeproducer.cpp, 112>: Return frame 4
...

There seems to be have some bugs, is there any known bugs, and how can i cope with these issues, thanks.
nveglstreamsrctest.tar.gz (5.11 KB)
log.txt (113 KB)

Hi SongjianSu,
[s]For FIFO=4, you can only have 4 buffers in your application. If you need 10 buffers, please set FIFO=10. UPDATE nveglstreamsrc supports max buffers=8, so max FIFO=8 also.
and please use the buffers in ring mode:
present frame 1
present frame 2
present frame 3
present frame 4 // app owns no frame
return frame… get frame 3 // app owns frame 1 2 3
present frame 1
present frame 2
present frame 3 // app owns no frame
return frame… get frame 2 // app owns frame 4 1 2
present frame 4
present frame 1
present frame 2 // // app owns no frame
return frame… gst frame 4 // app owns frame 3 4

We have customers run it successfully. If you cannot get it work, you should check your code. We have helped debug your code in #8, #9, and cannot always do the favor.[/s]

UPDATE The above comment is wrong. Please refer to #9 [url]https://devtalk.nvidia.com/default/topic/1023481/jetson-tx2/frames-returned-from-nveglstreamsrc-via-egl-stream-out-of-order/post/5209249/#5209249[/url]

I am sad to hear that, but I think I am helping report the bug. As you say, I set FIFO=10, and present 10 buffers, it still not working, and the pipepline report error message:
0:00:00.114342482 6205 0x656320 ERROR nveglstream gstnveglstreamsrc.c:570:gst_nvconsumer_buffer_pool_release_buffer: Failed to release EGLStream Frame.

nvidia@tegra-ubuntu:~/program/nveglstreamsrctest$ GST_DEBUG=3 ./nveglstreamsrctest 
CUDA producer initializing EGL display.
EGL API: 1.5
CUDA producer initializing EGL stream.
EGL Stream consumer - Mode: FIFO, Length: 10, latency 0.

NvEglStreamSrcInitializeEgl: Load library: libEGL.so
0:00:00.056235207  6205       0x656320 FIXME                default gstutils.c:3766:gst_pad_create_stream_id_internal:<nveglstreamsrc0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id
Connect EGL stream to cuda producer.
CUDA producer present frame: 0x5c2600000 used time 0 ms.
CUDA producer present frame: 0x5c2800000 used time 0 ms.
CUDA producer present frame: 0x5c2a00000 used time 0 ms.
CUDA producer present frame: 0x5c2c00000 used time 0 ms.
CUDA producer present frame: 0x5c2e00000 used time 0 ms.
CUDA producer present frame: 0x5c3000000 used time 0 ms.
CUDA producer present frame: 0x5c3200000 used time 0 ms.
CUDA producer present frame: 0x5c3400000 used time 0 ms.
CUDA producer present frame failed: 999.
============= wait some time =============
Returned frame 0x5c2600000 used time 0 ms.
0:00:00.114223154  6205       0x656320 ERROR            nveglstream gstnveglstreamsrc.c:570:gst_nvconsumer_buffer_pool_release_buffer:<nveglstreamsrc0> Failed to release EGLStream Frame.
0:00:00.114298386  6205       0x656320 ERROR            nveglstream gstnveglstreamsrc.c:570:gst_nvconsumer_buffer_pool_release_buffer:<nveglstreamsrc0> Failed to release EGLStream Frame.
0:00:00.114342482  6205       0x656320 ERROR            nveglstream gstnveglstreamsrc.c:570:gst_nvconsumer_buffer_pool_release_buffer:<nveglstreamsrc0> Failed to release EGLStream Frame.
Present a new frame 1.
CUDA producer present frame: 0x5c2600000 used time 0 ms.
Returned frame 0x5c2800000 used time 0 ms.
Present a new frame 2.
CUDA producer present frame: 0x5c2800000 used time 0 ms.
^C
nvidia@tegra-ubuntu:~/program/nveglstreamsrctest$

Hi SongjianSu, I have corrected #19. Max number of buffer is 8.

Hi DaneLLL, using max number of buffer size 8 still failed, and even crashed.

nvidia@tegra-ubuntu:~/program/nveglstreamsrctest$ GST_DEBUG=3 ./nveglstreamsrctest 
CUDA producer initializing EGL display.
EGL API: 1.5
CUDA producer initializing EGL stream.
EGL Stream consumer - Mode: FIFO, Length: 8, latency 0.

NvEglStreamSrcInitializeEgl: Load library: libEGL.so
0:00:00.054814732  6840       0x656320 FIXME                default gstutils.c:3766:gst_pad_create_stream_id_internal:<nveglstreamsrc0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id
Connect EGL stream to cuda producer.
CUDA producer present frame: 0x5c2600000 used time 0 ms.
CUDA producer present frame: 0x5c2800000 used time 0 ms.
CUDA producer present frame: 0x5c2a00000 used time 0 ms.
CUDA producer present frame: 0x5c2c00000 used time 0 ms.
CUDA producer present frame: 0x5c2e00000 used time 0 ms.
CUDA producer present frame: 0x5c3000000 used time 0 ms.
CUDA producer present frame: 0x5c3200000 used time 0 ms.
CUDA producer present frame: 0x5c3400000 used time 0 ms.
============= wait some time =============
Returned frame 0x5c2600000 used time 0 ms.
[b]0:00:00.118492119  6840       0x656320 ERROR            nveglstream gstnveglstreamsrc.c:570:gst_nvconsumer_buffer_pool_release_buffer:<nveglstreamsrc0> Failed to release EGLStream Frame.
0:00:00.118540312  6840       0x656320 ERROR            nveglstream gstnveglstreamsrc.c:570:gst_nvconsumer_buffer_pool_release_buffer:<nveglstreamsrc0> Failed to release EGLStream Frame.
0:00:00.118566296  6840       0x656320 ERROR            nveglstream gstnveglstreamsrc.c:570:gst_nvconsumer_buffer_pool_release_buffer:<nveglstreamsrc0> Failed to release EGLStream Frame.[/b]
Present a new frame 1.
CUDA producer present frame: 0x5c2600000 used time 0 ms.
Returned frame 0x5c2800000 used time 0 ms.
Present a new frame 2.
CUDA producer present frame: 0x5c2800000 used time 0 ms.
Returned frame 0x5c2a00000 used time 0 ms.
Present a new frame 3.
CUDA producer present frame: 0x5c2a00000 used time 0 ms.
^C
nvidia@tegra-ubuntu:~/program/nveglstreamsrctest$ GST_DEBUG=3 ./nveglstreamsrctest 
CUDA producer initializing EGL display.
EGL API: 1.5
CUDA producer initializing EGL stream.
EGL Stream consumer - Mode: FIFO, Length: 8, latency 0.

NvEglStreamSrcInitializeEgl: Load library: libEGL.so
Connect EGL stream to cuda producer.
0:00:00.063842570  6848       0x656320 FIXME                default gstutils.c:3766:gst_pad_create_stream_id_internal:<nveglstreamsrc0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id
CUDA producer present frame: 0x5c2600000 used time 1 ms.
CUDA producer present frame: 0x5c2800000 used time 0 ms.
CUDA producer present frame: 0x5c2a00000 used time 0 ms.
CUDA producer present frame: 0x5c2c00000 used time 0 ms.
CUDA producer present frame: 0x5c2e00000 used time 0 ms.
CUDA producer present frame: 0x5c3000000 used time 0 ms.
CUDA producer present frame: 0x5c3200000 used time 0 ms.
<b>0:00:00.124332668  6848       0x656320 ERROR            nveglstream gstnveglstreamsrc.c:570:gst_nvconsumer_buffer_pool_release_buffer:<nveglstreamsrc0> Failed to release EGLStream Frame.</b>
CUDA producer present frame: 0x5c3400000 used time 0 ms.
<b>CUDA producer present frame failed: 999.</b>
============= wait some time =============
Returned frame 0x5c2600000 used time 0 ms.
Present a new frame 1.
<b>Segmentation fault (core dumped)</b>
nvidia@tegra-ubuntu:~/program/nveglstreamsrctest$

Hi SongjianSu,
Please run as #9
[url]https://devtalk.nvidia.com/default/topic/1023481/jetson-tx2/frames-returned-from-nveglstreamsrc-via-egl-stream-out-of-order/post/5209249/#5209249[/url]

After calling present_Frame(n), call return_Frame(n-1).

The mode I mentioned in #19 does not work. Sorry for making confusion.

Hi DaneLLL, So in fact we can only keep 2 frames at most in the EGL stream FIFO.

I can see 3 frames at most in my test.