Skip to content
This repository has been archived by the owner on Oct 27, 2020. It is now read-only.

Threads that throw unhandled exceptions that are not the main opmode thread irrecoverably crash the RC app #680

Open
guineawheek opened this issue Jan 8, 2019 · 0 comments

Comments

@guineawheek
Copy link

This has been a fairly longstanding issue and it can be triggered from both internal SDK code (under rare circumstances) and team code. Generally, if a thread that is not the main OpMode or LinearOpMode thread throws an exception, the entire app will crash to the homescreen and the team will be unable to recover for the rest of the match. This thread can either be started by code written by the team, or an internally such as used in Vuforia or TFLite processing through bugs in the SDK.

One can reproduce this issue with a simple OpMode that looks something like this:

package org.firstinspires.ftc.teamcode;

import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;

@TeleOp(name="crash", group="crash")
public class KillApp extends OpMode {
    @Override
    public void init() {}
    
    @Override
    public void start() {
        new Thread() {
            public void run() {
                throw new RuntimeException("Robot controller crash!");
            }
        }.start();
    }

    @Override
    public void loop() {}
}

One solution to this issue is simply setting a default exception handler for all threads. [This gist will restart the robot controller on a crash] (https://gist.github.com/guineawheek/ea7390854c3f9ecaca56d6ad1ad630fe), although for different threads different responses may be more appropriate to reduce downtime.

@guineawheek guineawheek changed the title threads that throw unhandled exceptions that are not the main opmode thread irrecoverably crash the RC app Threads that throw unhandled exceptions that are not the main opmode thread irrecoverably crash the RC app Jan 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant