Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The tree_source example is problematic #1994

Open
rmartin16 opened this issue Jun 19, 2023 · 3 comments
Open

The tree_source example is problematic #1994

rmartin16 opened this issue Jun 19, 2023 · 3 comments
Labels
bug A crash or error in behavior. linux The issue relates Linux support.

Comments

@rmartin16
Copy link
Member

rmartin16 commented Jun 19, 2023

Describe the bug

The tree_source example creates a lazy-loading tree view of the current directory.

  1. When used with Briefcase (dev or run), the cwd is $HOME.....the app loaded 10GB in to memory before i killed it
  2. It doesn't seem to actually be lazy.....it tried to read my entire home directory before showing the window
  3. It completely bombs out on a node if anything causes an OSError...for instance, a broken symlink in my home dir

Steps to reproduce

Run briefcase dev for the tree_source example

Expected behavior

The directory used for the tree is enforced to be the directory of the app and it is actually lazy.

Screenshots

No response

Environment

  • Operating System: pop os 22.04
  • Python version: 3.10.12
  • Software versions:
    • Briefcase: 0.3.15.dev361+g02f412be.d20230619
    • Toga: 0.3.2.dev383+g7d68e74d.d20230619

Logs

No response

Additional context

No response

@rmartin16 rmartin16 added the bug A crash or error in behavior. label Jun 19, 2023
@rmartin16
Copy link
Member Author

Additionally, the tree doesn't seem to load anything on Windows and there isn't any visible error. I can't identify the breakdown though.

@freakboy3742
Copy link
Member

The breakdown is that tree isn't implemented on Windows :-)

Or, rather, the implementation is known to be broken, because Winforms doesn't support multiple columns of content in a Tree. Some of the recent discussions about a "Simple Tree" widget extend from this limitation.

@freakboy3742
Copy link
Member

Ok - so... the tree_source demo does do lazy loading (at least, as of #2017)... but that's only as good as the backend implementation.

Cocoa's implementation uses a view on the data source - it only renders what is visible, and asks for data on a cell-by-cell basis. Cells aren't expanded by default, and expandability is determined by the can_have_children attribute, which is determined based on whether the node is a file or a directory. The children aren't evaluated until you try to access the list of children, and this doesn't happen until a child is actually rendered.

GTK builds a full tree data model when it is loaded - which means creating all the children. #1978 has flagged that GTK has deprecated Gtk.TreeStore in favour of Gtk.ListModel, and from a casual inspection, it looks like that is more amenable to an "interface" based implementation; this might provide a way to fix the problem by making the GTK ListModel feeding the tree an API wrapper around the Toga TreeSource.

@freakboy3742 freakboy3742 added the linux The issue relates Linux support. label Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash or error in behavior. linux The issue relates Linux support.
Projects
None yet
Development

No branches or pull requests

2 participants