javacv
javacv copied to clipboard
JVM crash when getting frame from JAVA 2D
Im using FFmpeg Frame Grabber and convert Convert frames to Buffered Image using Java2DFrameGrabber, but my JVM crash, I not always but im seeing it quite often now. Im using version 1.5.4
2022-02-25 12:51:19,354 ERROR c.i.w.ColorDetectionTask$ColorDetector: Error Extracting Frame 2022-02-25 12:51:19,354 TRACE c.i.w.ColorDetectionTask$ColorDetector: org.bytedeco.javacv.FrameGrabber$Exception: Could not grab: No AVFormatContext. (Has start() been called?) at org.bytedeco.javacv/org.bytedeco.javacv.FFmpegFrameGrabber.grabFrame(FFmpegFrameGrabber.java:1254) at org.bytedeco.javacv/org.bytedeco.javacv.FFmpegFrameGrabber.grabImage(FFmpegFrameGrabber.java:1239) at com.viewer.remote.NormalGrabber.getFrame(NormalGrabber.java:126)
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000002b710fdc9db, pid=19876, tid=18500
#
# JRE version: OpenJDK Runtime Environment (11.0.4+11) (build 11.0.4+11)
# Java VM: OpenJDK 64-Bit Server VM (11.0.4+11, mixed mode, tiered, compressed oops, g1 gc, windows-amd64)
# Problematic frame:
# J 16546 c2 org.bytedeco.javacv.Java2DFrameConverter.flipCopyWithGamma(Ljava/nio/ByteBuffer;IILjava/nio/ByteBuffer;IIZDZI)V org.bytedeco.javacv (635 bytes) @ 0x000002b710fdc9db [0x000002b710fdc660+0x000000000000037b]
#
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# hs_err_pid19876.log
Compiled method (c2) 185640 16546 4 org.bytedeco.javacv.Java2DFrameConverter::flipCopyWithGamma (635 bytes)
total in heap [0x000002b710fdc490,0x000002b710fdd520] = 4240
relocation [0x000002b710fdc608,0x000002b710fdc640] = 56
constants [0x000002b710fdc640,0x000002b710fdc660] = 32
main code [0x000002b710fdc660,0x000002b710fdd020] = 2496
stub code [0x000002b710fdd020,0x000002b710fdd038] = 24
oops [0x000002b710fdd038,0x000002b710fdd048] = 16
metadata [0x000002b710fdd048,0x000002b710fdd088] = 64
scopes data [0x000002b710fdd088,0x000002b710fdd3d8] = 848
scopes pcs [0x000002b710fdd3d8,0x000002b710fdd4c8] = 240
dependencies [0x000002b710fdd4c8,0x000002b710fdd4d0] = 8
handler table [0x000002b710fdd4d0,0x000002b710fdd4e8] = 24
nul chk table [0x000002b710fdd4e8,0x000002b710fdd520] = 56
Could not load hsdis-amd64.dll; library not loadable; PrintAssembly is disabled
Could not grab: No AVFormatContext. (Has start() been called?) at
Please call start()!
but the JVM should not crash? Another example is below, when we set the timestamp to get BufferedImage on a certain time of video file. There was no start exception in that instance.
` Command Line: -Xms30G -XX:+UseConcMarkSweepGC -Dj2e.class.path=;C:\Program Files\imageApp\imageApp.;.;C:\Program Files (x86)\QuickTime\QTSystem\QTJava.zip -Dj2e.app.path=C:\Program Files\imageApp\imageApp\imageApp.exe -Dapplication.home=C:\Program Files\imageApp\imageApp\ -Dj2e.is.elevated=true
Host: Intel(R) Xeon(R) Silver 4114 CPU @ 2.20GHz, 40 cores, 63G, Windows 10 , 64 bit Build 19041 (10.0.19041.1503) Time: Fri Mar 4 13:45:01 2022 GMT Standard Time elapsed time: 259 seconds (0d 0h 4m 19s)
--------------- T H R E A D ---------------
Current thread (0x0000000048a85000): JavaThread "pool-11-thread-1" [_thread_in_native, id=40284, stack(0x000000089e0c0000,0x000000089e2c0000)]
Stack: [0x000000089e0c0000,0x000000089e2c0000], sp=0x000000089e2bf060, free space=2044k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) C 0x00007fff4027a25b
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) j org.bytedeco.ffmpeg.global.avcodec.avcodec_flush_buffers(Lorg/bytedeco/ffmpeg/avcodec/AVCodecContext;)V+0 J 11853 c1 org.bytedeco.javacv.FFmpegFrameGrabber.setTimestamp(JLjava/util/EnumSet;)V (606 bytes) @ 0x000000000f4d2f44 [0x000000000f4d2d00+0x0000000000000244] j org.bytedeco.javacv.FFmpegFrameGrabber.setVideoTimestamp(J)V+8`
It can crash if the memory allocated for your images gets deallocated prematurely. You'll need to make sure that doesn't happen.
It can crash if the memory allocated for your images gets deallocated prematurely. You'll need to make sure that doesn't happen.
Thank you the issue is resolved, the problem was for corrupt videos the setVideo method fails.
And we were extracting videos on mouse movements on panel.
I need to make sure if setVideo method fails, the code can't try to extract frame.
Does it crash when only calling setVideoTimestamp()? If so, please attach a sample video file that causes the crash. I'm sure @anotherche can look into that. Thanks!