Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8094037

TreeView creates cells for every item from start to scrollTo position

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • P4
    • None
    • 7u6
    • javafx
    • JavaFX 2.2b13, Windows 7

    Description

      I'm not 100% sure this is a new problem, but it has gotten pretty noticable recently. I've got an app that display about 300 items in a TreeView, with about 20 orso visible at a time. My app remembers the scroll position and returns you to this position when you get back to the same view. These items are expensive to display as they are linked to a database, so great care is taken in my app to avoid unnecessary loading of data until a Cell of such an item is actually required.

      However, it now turns out that when scrolling to about halfway into the view (to item 150 for example), all items in between will be accessed and created cells for. None of the items above 150 will be accessed apart from a few that are also being displayed nearby item 150.

      The desired behaviour would be more in line of only creating cell #150, and then working up and down to fill up the view instead of creating them all.

      Note: I can understand TreeView creating cells 0-20 because scrollTo() isn't called immediately after construction (due to other issues scrollTo doesn't work in all cases at such an early time)... but it has no business creating cells 21-140.

      Note2: This TreeView is mostly one big flat space (one root node (not displayed) and 300 children, with only occasionally a child node that has 2 or 3 children of its own).

      Attached a stack trace that shows scrollTo being the root cause:

      java.lang.Exception
      at hs.mediasystem.enrich.EnrichCache.enrich(EnrichCache.java:210)
      at hs.mediasystem.enrich.EnrichCache.enrich(EnrichCache.java:158)
      at hs.mediasystem.framework.MediaItem.queueForEnrichment(MediaItem.java:153)
      at hs.mediasystem.enrich.DefaultEnrichable.queueForEnrichment(DefaultEnrichable.java:32)
      at hs.mediasystem.framework.Media.access$0(Media.java:1)
      at hs.mediasystem.framework.Media$4.get(Media.java:66)
      at hs.mediasystem.framework.Media$4.get(Media.java:1)
      at javafx.beans.binding.ObjectExpression.getValue(ObjectExpression.java:47)
      at com.sun.javafx.binding.ExpressionHelper.addListener(ExpressionHelper.java:73)
      at javafx.beans.property.ObjectPropertyBase.addListener(ObjectPropertyBase.java:95)
      at hs.mediasystem.util.MapBindings$Helper.computeValue(MapBindings.java:190)
      at hs.mediasystem.util.MapBindings$5.computeValue(MapBindings.java:148)
      at javafx.beans.binding.ObjectBinding.get(ObjectBinding.java:152)
      at javafx.beans.binding.ObjectExpression.getValue(ObjectExpression.java:47)
      at com.sun.javafx.binding.ExpressionHelper.addListener(ExpressionHelper.java:73)
      at javafx.beans.binding.ObjectBinding.addListener(ObjectBinding.java:71)
      at javafx.beans.binding.StringBinding.bind(StringBinding.java:101)
      at hs.mediasystem.screens.MediaItemFormatter$1.<init>(MediaItemFormatter.java:23)
      at hs.mediasystem.screens.MediaItemFormatter.releaseYearBinding(MediaItemFormatter.java:18)
      at hs.mediasystem.ext.media.movie.MovieCell.configureCell(MovieCell.java:21)
      at hs.mediasystem.screens.SmartMediaNodeCellProvider.getConfiguredGraphic(SmartMediaNodeCellProvider.java:23)
      at hs.mediasystem.ext.selectmedia.tree.TreeListPane$MediaItemTreeCell.updateItem(TreeListPane.java:250)
      at hs.mediasystem.ext.selectmedia.tree.TreeListPane$MediaItemTreeCell.updateItem(TreeListPane.java:1)
      at javafx.scene.control.TreeCell.updateItem(TreeCell.java:405)
      at javafx.scene.control.TreeCell.access$000(TreeCell.java:67)
      at javafx.scene.control.TreeCell$1.invalidated(TreeCell.java:95)
      at com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:155)
      at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:100)
      at javafx.beans.property.ReadOnlyIntegerWrapper$ReadOnlyPropertyImpl.fireValueChangedEvent(ReadOnlyIntegerWrapper.java:195)
      at javafx.beans.property.ReadOnlyIntegerWrapper.fireValueChangedEvent(ReadOnlyIntegerWrapper.java:161)
      at javafx.beans.property.IntegerPropertyBase.markInvalid(IntegerPropertyBase.java:130)
      at javafx.beans.property.IntegerPropertyBase.set(IntegerPropertyBase.java:163)
      at javafx.scene.control.IndexedCell.updateIndex(IndexedCell.java:112)
      at com.sun.javafx.scene.control.skin.VirtualFlow.setCellIndex(VirtualFlow.java:1590)
      at com.sun.javafx.scene.control.skin.VirtualFlow.getCell(VirtualFlow.java:1494)
      at com.sun.javafx.scene.control.skin.VirtualFlow.getCellLength(VirtualFlow.java:1517)
      at com.sun.javafx.scene.control.skin.VirtualFlow.scrollTo(VirtualFlow.java:1842)
      at com.sun.javafx.scene.control.skin.VirtualContainerBase.handleControlProperties(VirtualContainerBase.java:107)
      at com.sun.javafx.scene.control.skin.VirtualContainerBase.access$000(VirtualContainerBase.java:43)
      at com.sun.javafx.scene.control.skin.VirtualContainerBase$1.onChanged(VirtualContainerBase.java:59)
      at com.sun.javafx.collections.MapListenerHelper$SingleChange.fireValueChangedEvent(MapListenerHelper.java:133)
      at com.sun.javafx.collections.MapListenerHelper.fireValueChangedEvent(MapListenerHelper.java:47)
      at com.sun.javafx.collections.ObservableMapWrapper.callObservers(ObservableMapWrapper.java:94)
      at com.sun.javafx.collections.ObservableMapWrapper.put(ObservableMapWrapper.java:146)
      at javafx.scene.control.TreeView.scrollTo(TreeView.java:784)
      at hs.mediasystem.ext.selectmedia.tree.TreeListPane$8.run(TreeListPane.java:316)
      at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
      at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
      at com.sun.glass.ui.win.WinApplication$2$1.run(WinApplication.java:62)
      at java.lang.Thread.run(Thread.java:722)

      Attachments

        Activity

          People

            jgiles Jonathan Giles
            jhendrikx John Hendrikx
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: