mastodon-sc / mastodon

Mastodon – a large-scale tracking and track-editing framework for large, multi-view images.
BSD 2-Clause "Simplified" License
67 stars 20 forks source link

JVM crashes after modifying the graph in TrackScheme. #34

Closed tinevez closed 7 years ago

tinevez commented 7 years ago

It can happen that the Mastodon crashes when modifying the graph several times via its highlight or focus.

The diagnosis is as follow (based on the unify-views branch):

A graphChanged event ends up in calling the paint() method of the TrackSchemePanel.

The paint() method does mainly two things, in the following order:

This issue is caused by the fact that several classes are notified when the layout() method is finished, and interrogate the ScreenEntities. For instance for this bug:

  1. A graphChanged event ends up in calling the paint() method of the TrackSchemePanel.

  2. The paint() method calls the layout() method of the LineageTreeLayout class.

  3. When the layout is done, The LayoutListener of the class are notified (via `layoutChanged()).

  4. One of these listener is the InertialScreenTransformListener. It notifies its TransformListener (via transformChanged()).

  5. This transform listener is theInteractiveDisplayCanvasComponent`. It has several listeners it forward this event to.

  6. One of them is the MouseHighlightHandler. Calling its transformChanged() method causes it to try an grab the currently highlighted edge or vertex.

  7. To do so, it calls the getEdgeAt() or getVertexAt() method of the AbstractTrackSchemeOverlay class.

  8. These two methods rely on ScreenEntities to retrieve the desired TrackScheme item, but at this time, they are not valid. They link to TrackScheme items that may have been deleted or moved. Calling a second graph modification event with these items is what causes the crash.

tpietzsch commented 7 years ago

@tinevez thanks for finding this out!

tpietzsch commented 7 years ago

@tinevez I have a tentative fix for this. It requires addition of a RefPool.getIfExists() method, so it touches all mastodon projects:

https://github.com/bigdataviewer/mastodon-collection/tree/safe-get-object https://github.com/bigdataviewer/mastodon-graph/tree/safe-get-object https://github.com/fiji/TrackMate3/tree/safe-get-object

Can you have a look? If everything is ok, I'll merge and release...

tinevez commented 7 years ago

Sorry for delayed response.

Yes it works! The crash is gone!