mbari-org / vars-annotation

Video Annotation Application for MBARI's Media Management (M3) software stack
https://docs.mbari.org/vars-annotation/
Apache License 2.0
16 stars 6 forks source link

Concept buttons are not always showing up when a user logs in or refreshes #179

Closed hohonuuli closed 4 months ago

hohonuuli commented 7 months ago

Look into issues inside ConceptButtonPaneController and ConceptButtonPanesController.

kwalz commented 7 months ago

Just a quick note that when I was annotating remotely last Friday over vpn, I never lost my concept buttons on maps even after opening 12 files. It's interesting that it works from home over a slow vpn, not sure if this is a clue to help solve but thought I would add it here.

kwalz commented 5 months ago

@hohonuuli This issue along with the localization box drawing issue (https://github.com/mbari-org/vars-annotation/issues/174) are high priority and hopefully can be solved together, if they are both related to timing of opening up application.

hohonuuli commented 5 months ago

@kwalz Just a note that, while I suspect both these issues are related to timing/multithreading, they are actually unrelated to each other. ATM, I'll be prioritizing the #174 and hope to start work on it Monday.

hohonuuli commented 4 months ago

I add the following changes:

  1. load/saves for the concept buttons and quick association buttons are done on a single threaded executor service to avoid any interleaving of user account data.
  2. I found that the missing buttons were being loaded but the UI wasn't redrawing them (at least until the user manually resized the window.) To fix this I added a ForceRedrawEvent that can be sent on the internal eventbus. The App class has this lovely little hack. I change the window width by 1 pixel, allow the JavaFX internal thread to to a redraw tick (that's the sleep fro 100ms), then change it back. Works like a champ.
    toolBox.getEventBus()
                .toObserverable()
                .ofType(ForceRedrawEvent.class)
                .subscribe(e -> {
                    var width = primaryStage.getWidth();
                    toolBox.getExecutorService().submit(() -> {
                        Platform.runLater(() -> {
                            primaryStage.setWidth(width + 1);
                        });
                        try {
                            // Let the UI thread catch up and redraw
                            Thread.sleep(100);
                        } catch (InterruptedException ex) {
                            // no-op
                        }
                        Platform.runLater(() -> {
                            primaryStage.setWidth(width);
                        });
                    });
                });