Crash When Switching Between Aspects Rapidly

Issue #220 new
Calem Bendell created an issue

I think what caused this crash was simply switching between views too quickly and then attempting to use the keyboard, but that seems odd. A race hazard somewhere? That seems unlikely though. I closed one aspect, returning to the concern view, and opened another aspect, moving to make a new class immediately. When I began typing, TouchCORE crashed.

The exception is below:

Exception in thread "Animation Thread" java.lang.ClassCastException: ca.mcgill.ram.ui.scenes.DisplayAspectScene cannot be cast to ca.mcgill.sel.core.ui.scenes.DisplayConcernScene
    at ca.mcgill.sel.core.ui.handler.impl.KeyboardHandler.shouldDismissKeyboard(KeyboardHandler.java:45)
    at ca.mcgill.ram.ui.views.TextView.verifyKeyboardDismissed(TextView.java:269)
    at ca.mcgill.ram.ui.components.RamKeyboard.dimissKeyboard(RamKeyboard.java:752)
    at ca.mcgill.ram.ui.components.RamTextComponent.appendCharByUnicode(RamTextComponent.java:225)
    at ca.mcgill.ram.ui.components.RamKeyboard.keyPressed(RamKeyboard.java:538)
    at ca.mcgill.ram.ui.components.RamKeyboard.keyPressed(RamKeyboard.java:499)
    at org.mt4j.AbstractMTApplication.fireKeyPressed(AbstractMTApplication.java:1000)
    at org.mt4j.AbstractMTApplication.keyPressed(AbstractMTApplication.java:988)
    at processing.core.PApplet.handleKeyEvent(PApplet.java:1968)
    at ca.mcgill.ram.RamApp.handleKeyEvent(RamApp.java:411)
    at processing.core.PApplet.dequeueKeyEvents(PApplet.java:1951)
    at processing.core.PApplet.handleDraw(PApplet.java:1615)
    at processing.core.PApplet.run(PApplet.java:1502)
    at java.lang.Thread.run(Unknown Source)

Comments (5)

  1. Matthias Schoettle
    • edited description

    Someone also showed me a similar case (same exception) with BackgroundLayerHandler.processUnistrokeEvent(...) and (I believe) processTapAndHoldEvent(...). All of them use RamApplication.getActiveScene().

    I guess these events are handled during transitioning of scenes.

  2. Matthias Schoettle

    I can reproduce this one when clicking "Back" in an aspect and then trying to perform a unistroke gesture (clicking and moving the mouse around) during the transition:

    Exception in thread "Animation Thread" java.lang.ClassCastException: ca.mcgill.ram.ui.scenes.DisplayAspectScene cannot be cast to ca.mcgill.sel.core.ui.scenes.DisplayConcernScene
        at ca.mcgill.sel.core.ui.handler.impl.BackgroundLayerHandler.processUnistrokeEvent(BackgroundLayerHandler.java:131)
        at ca.mcgill.ram.ui.handler.BaseHandler.processGestureEvent(BaseHandler.java:97)
        at org.mt4j.input.GestureEventSupport.fire(GestureEventSupport.java:184)
        at org.mt4j.input.GestureEventSupport.fireGestureEvt(GestureEventSupport.java:169)
        at org.mt4j.components.MTComponent.processGestureEvent(MTComponent.java:3033)
        at org.mt4j.input.inputProcessors.componentProcessors.AbstractComponentProcessor.fireGestureEvent(AbstractComponentProcessor.java:236)
        at org.mt4j.input.inputProcessors.componentProcessors.AbstractCursorProcessor.fireGestureEvent(AbstractCursorProcessor.java:169)
        at org.mt4j.input.inputProcessors.componentProcessors.unistrokeProcessor.UnistrokeProcessor.cursorStarted(UnistrokeProcessor.java:82)
        at ca.mcgill.ram.events.UnistrokeProcessorLeftClick.cursorStarted(UnistrokeProcessorLeftClick.java:46)
        at org.mt4j.input.inputProcessors.componentProcessors.AbstractCursorProcessor.processInputEvtImpl(AbstractCursorProcessor.java:136)
        at org.mt4j.input.inputProcessors.componentProcessors.AbstractComponentProcessor.processInputEvent(AbstractComponentProcessor.java:87)
        at org.mt4j.input.ComponentInputProcessorSupport.processInputEvent(ComponentInputProcessorSupport.java:76)
    [...]
    
  3. Matthias Schoettle

    One way is to wait until after the transition is completed before performing the next gesture.

    In general, I think the scenes need to be refactored. Quite a few things can be moved into RamAbstractScene because it is common to all (or most) our scenes. Then, in some of the cases, no cast is necessary when getting the active scene.

    Common things include: Menu, top layer, unistroke layer, adding selector, request to close scene, ...

  4. Log in to comment