bigdataviewer / bigdataviewer-vistools

Helpers to use BigDataViewer as a quick visualization tool in other projects.
BSD 2-Clause "Simplified" License
25 stars 17 forks source link

Fix inconsistent setup ids #9

Closed igorpisarev closed 6 years ago

igorpisarev commented 7 years ago

@hanslovsky and I identified a bug that causes inconsistent order of setup ids using BdvFunctions.show() methods. When the first source is added, the viewer is not created yet, and BdvHandleFrame.add() creates it internally. But BdvHandleFrame.getUnusedSetupId() is called before that, and it uses setupAssignments object (which is null in the described case) to look up the max used id. It will store the new mapping null->1. If we save a bdv-settings.xml file, it will contain a description of the source with id=1.

The problem occurs when we want to display a source in another BDV window. The logic will be the same as above, but this time it will assign id=2 to the new source because of the existing null mapping. It will update the mapping with null->2. If we try to load the existing bdv-settings.xml file, it will throw an exception because the setup id is different. The expected behavior is that the setup ids are consistent across runs.

We came up with a solution to force creating the viewer before adding any sources, so that setupAssignments is never null.

tpietzsch commented 7 years ago

I see the problem but I don't like the solution. It breaks the initializing of the viewer transformation when the first source is added. I'll think of an alternative solution...

igorpisarev commented 6 years ago

I worked around this problem by not using bdv-vistools and instantiating BigDataViewer in my code instead (I needed to customize the viewer anyway). While the original issue remains, I am closing this PR as the proposed fix indeed doesn't play well with the viewer transformation.