![]() |
WPILIB Camera Code Crashing JVM
Hi All,
We're coding in Java and started experiencing problems with the robot becoming disabled after a random interval. Checking the logs from the dashboard we saw that we were getting a message. Checking the message we found that the JVM was crashing when getting an image using the WPILib native libraries... Code:
# If you would like to submit a bug report, please visit:CPU is at around 75% before the crash, drops to about 50, then 50 15 within a second or 2 until the code gets reloaded. I've attached the log file. Anyone we can talk to since the problem is outside our code? It seems to happen after a random interval between 3 and 8 minutes while the robot is enabled, even if sitting idle. This is a chunk of our Robot.java, pardon the duplicated code - it's a work in progress. Calling camera.getImage shouldn't crash the JVM on us. Eating the exception isn't a good idea either, including both to give the picture of what we actually have right now... Code:
public void robotInit() { |
Re: WPILIB Camera Code Crashing JVM
Not sure if this is related or not to your issue, but we had a problem with exhausting memory when grabbing images that would cause the robot code to crash and burn after running for a certain time period.
We found a fix (or work around) by invoking the free() method on the image objects returned after we were done with the image. The following provides an idea of what we did. Code:
// Grab image from USB camera and push out to camera serverAgain, not sure if this is related to the problem you are seeing (I didn't see anything in your error messages about running out of memory), but it might be something to try. Good luck. |
Re: WPILIB Camera Code Crashing JVM
Thanks for the advice, certainly worth a try. The WPI lib for imaging is all native alls, not pure java, so anything is possible...
|
Re: WPILIB Camera Code Crashing JVM
Quote:
|
Re: WPILIB Camera Code Crashing JVM
Quote:
|
Re: WPILIB Camera Code Crashing JVM
The free didn't help. If we were holding out a resource I'd expect to see the application (robot) start throwing out of memory errors, although it is possible that if the JVM is allocating memory and has been started with enough memory allocated that it's exhausting the OS's available memory it's being killed by the oom killer (beware the oom killer!). I'm not sure if that would create a crash report.
Maybe something in /var/logs could provide a clue? Even if I find it I'm not sure we'll be able to fix it since it's in WPI's native libraries somewhere. Any thoughts on who to contact for support on the WPI lib? |
Re: WPILIB Camera Code Crashing JVM
To provide some clarity, we can see from the stack from the JVM that we're in com.ni.vision.NIVision._Priv_ReadJPEGString in wpi's lib when the jvm crashes...
Code:
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)Code:
public static AxisCamera currentCamera; |
Re: WPILIB Camera Code Crashing JVM
Looking at the source for NIVision I think the .free() will work if used in a finally block. When we tried it the first time it didn't end up in a finally block and the image was being used as a member variable.
The NIVision class is calling C libraries that allocate memory outside the JVM so the correct steps we need are (pseudo code):
Will repost when we understand better. |
Re: WPILIB Camera Code Crashing JVM
Still crashing.
Here's the JVM version... Code:
gsmin@roboRIO-3932-FRC:/usr/local/frc/bin# /usr/local/frc/JRE/bin/java -version -XX:+PrintCommandLineFlagCode:
Mem: 176600K used, 75372K free, 0K shrd, 93K buff, 3067729088K cached |
Re: WPILIB Camera Code Crashing JVM
Here is our latest and cleanest code with all the logic encapsulated in a single class. This still crashes the JVM...
Code:
public class CameraConfig { |
What happens if you make image a class variable? Allocating and deallocating it are expensive.
It also looks like you are using last years JRE. |
Re: WPILIB Camera Code Crashing JVM
Quote:
We flashed all our roboRIOs this year, what makes you think it's last years Java version? I'll check on our end to make sure the RIOs are all running build 1.8.0_06-b23, I don't think they would work at all if we hadn't flashed them. Can you post a link or provide info. on why you think the JVM version is wrong and where/how we'd get the right one? Thanks for your help! |
Re: WPILIB Camera Code Crashing JVM
Quote:
|
Re: WPILIB Camera Code Crashing JVM
Quote:
(there must be a good reason that wpilib isn't using finalize() to call free() - maybe finalize is unreliable?) Anyway, I have to go with the previously stated recommendation, that you reuse the same image object. NI vision allows you to do that. |
| All times are GMT -5. The time now is 07:54 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi