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

Refactoring: Lazy init of all editor tabs #3333

Merged
merged 5 commits into from
Oct 23, 2017
Merged

Conversation

tobiasdiez
Copy link
Member

@tobiasdiez tobiasdiez commented Oct 22, 2017

Not to let @halirutan and @lenhard have all the fun, I'll jump onto the "improve-the-entry-editor"-train. So this PR is a natural continuation of #3331.

Changes:

  • The entry editor tabs are only initialized once and then later notified about getting the focus or the change of entry.
  • The different tabs no longer rely on the JabRefFrame and BasePanel (finally!)
  • I removed some commented-out code in the FieldsEditorTab, that was a relic of previous (incomplete) refactorings.
  • Disable tab animation.

  • Change in CHANGELOG.md described
  • Tests created for changes
  • Screenshots added (for bigger UI changes)
  • Manually tested changed features in running JabRef
  • Check documentation status (Issue created for outdated help page at help.jabref.org?)
  • If you changed the localization: Did you run gradle localizationUpdate?

@halirutan
Copy link
Collaborator

Nice! I pulled your branch and I'm looking over it. One thing up front: As expected, the memory consumption went again down drastically and the same run through the 209 entry example was now possible even without the GC kicking in

img

I see here only 240MB of RAM that was needed and the speed is awesome.

@halirutan
Copy link
Collaborator

With the changes, tabs no longer fly-in but for some reason, the order is not preserved.

This is just horrible. The sorting of the observable list tabbed.getTabs() is correct all the time. The some reason for the reordering is in com.sun.javafx.scene.control.skin.TabPaneSkin. SetAll in your code works so smoothly since the skin does not really set the list. It maintains a to be removed and to be added list and unfortunately, it inserts new elements, like the FileAnnotation tab that is often not accessible at the front.

Even more unfortunate is that the TabPaneSkin is an almost completely inaccessible class. Everything important is private. I guess we will have to do the removing and insertion of tabs ourselves.

I thought maybe we can simply have all tabs in tabbed and close and open them. Therefore,
I looked into what closing a tab means but it's really just removing the tab from the list. See com.sun.javafx.scene.control.behavior.TabPaneBehavior#closeTab for details. That's the reason why you don't find a open tab there.

The best solution from the developer's point of view is disabling the tabs. We wouldn't even have to keep a tabs variable then. If this is absolutely no way to go, then we need to write a small algorithm that (a) removes unwanted tabs from the existing list and (b) inserts new tabs that were not in there at the right position.

@halirutan
Copy link
Collaborator

halirutan commented Oct 22, 2017

I don't have push access, but here is the patch for manually changing the tabs list without removing everything and re-adding all tabs. In IDEA you can try it out by using VCS -> Apply Patch.

@tobiasdiez
Copy link
Member Author

Thanks @halirutan for the feedback and the patch. I took your ideas but implemented it somewhat different (the outcome should be the same). Everything seems to work now, so this PR is ready for review.

@tobiasdiez tobiasdiez added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Oct 23, 2017
Copy link
Member

@Siedlerchr Siedlerchr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code wise looks good to me. Will test it outl ater

@lenhard
Copy link
Member

lenhard commented Oct 23, 2017

Great job overall. The code looks fine. I have nothing to criticize expect my usual stuff: Please add a changelog entry :-)

Here's an example of when I really try to push the entry editor to the limits with having key down pressed in the main table:
keydown
That is excellent, I am not getting JabRef above 800 MB. I also have the impression that GC is kicking in much more frequently. Here is also a diagram of some "longer" development:
longer
You can see the initial spikes. Then during idle time, memory stays up and it takes some time for GC to start. What annoys me is that JabRef does not free more unused heap, but I would probably have to wait longer for that and in the end it is a different issue.

What I haven't tested extensively is that the entry editor actually works, i.e. that updates in the entry editor go to the right entry. I was surprised that I don't see many changes in the update structure in the code in this PR, but maybe it was simpler to achieve than I expected. I wouldn't be surprised if we find update bugs after merging this.

TL&DR: Very cool PR. It is almost ready to merge in my point of view.

@tobiasdiez
Copy link
Member Author

@lenhard We already have a changelog entry for the performance improvements, so I didn't added anything there in addition.

@koppor I expect at least few beers from you for everybody at the next JabCon for bearing the constant annoying stylecheck complains 😺

@koppor
Copy link
Member

koppor commented Oct 23, 2017 via email

@lenhard lenhard changed the title [WIP] Refactoring: Lazy init of all editor tabs Refactoring: Lazy init of all editor tabs Oct 23, 2017
@lenhard
Copy link
Member

lenhard commented Oct 23, 2017

@tobiasdiez Alright, I am fine with that. I have removed the [WIP] part in the title, since this is no longer work in progress, I guess.

We're practically good to go here, right? @Siedlerchr wanted to do some more testing and then we can merge.

@Siedlerchr
Copy link
Member

Tried around, works amazingly fast! Did not find any issue so far, so I would merge it now!
Thanks all contributors!

@Siedlerchr Siedlerchr merged commit b61cc98 into master Oct 23, 2017
@Siedlerchr Siedlerchr deleted the refactorEntryEditor branch October 23, 2017 16:22
Siedlerchr added a commit that referenced this pull request Oct 24, 2017
* upstream/master:
  update mockito-core from 2.10.0 -> 2.11.0 (#3338)
  Remove underscore in Localized messages (#3336)
  Localisation: French: new entries translated (#3337)
  Refactoring: Lazy init of all editor tabs (#3333)
Siedlerchr added a commit that referenced this pull request Oct 25, 2017
* upstream/master:
  Fix NPE when calling with bib file as cmd argument (#3343)
  update mockito-core from 2.10.0 -> 2.11.0 (#3338)
  Remove underscore in Localized messages (#3336)
  Localisation: French: new entries translated (#3337)
  Refactoring: Lazy init of all editor tabs (#3333)
Siedlerchr added a commit that referenced this pull request Oct 27, 2017
* upstream/master: (31 commits)
  Source tab entry duplication (#3360)
  Use CITE_COMMENT not only for external latex editors but also for cop… (#3351)
  Updating with new translations (#3348)
  Upgrade error-prone (#3350)
  Jabref_pt_BR partially updated (#3349)
  Used late initialization for context menus (#3340)
  Fix NPE when calling with bib file as cmd argument (#3343)
  update mockito-core from 2.10.0 -> 2.11.0 (#3338)
  Remove underscore in Localized messages (#3336)
  Localisation: French: new entries translated (#3337)
  Refactoring: Lazy init of all editor tabs (#3333)
  Initializing EntryEditor Tabs on focus (#3331)
  Fix #3292: annotations are now automatically refreshed (#3325)
  Change integrity message for names depending on database mode (#3330)
  Fix location bundle with fast access (#3327)
  Small code cleanup
  Fix "path not found" exception
  Small fix in drag and drop handler of linked files (#3328)
  Fix NPE in MainTable (#3318)
  Increase relative size of abstract field in editor (#3320)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants