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

fix: Don't repeatedly recreate the last marker block during a drag. #6875

Merged
merged 2 commits into from
Mar 1, 2023

Conversation

gonfunko
Copy link
Contributor

@gonfunko gonfunko commented Mar 1, 2023

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide
  • I ran npm run format and npm run lint

The details

Resolves

Fixes #6839

Proposed Changes

#5722 introduced logic to update the available connections (and marker block) for a block being dragged as it was being dragged in order to make the marker block reflect changes to the connections of the block being dragged that happened during the drag. The insertion marker corresponding the first block in the stack being dragged was only regenerated when (a) it was shown and (b) its connections were inconsistent with those on the corresponding insertion marker block. However, the insertion marker corresponding to the last block in the stack was recreated every time the drag moved. This PR updates the insertion marker manager to only create the insertion marker block corresponding to the last block in the stack being dragged (a) at the beginning of the drag and (b) in the event of the same sort of mismatch during showing that would cause the insertion marker block corresponding to the first block in the stack being dragged to be regenerated.

Behavior Before Change

Numerous useless block creations.

Behavior After Change

Insertion marker blocks are only created on an as-needed basis.

@gonfunko gonfunko requested a review from a team as a code owner March 1, 2023 23:03
@gonfunko gonfunko requested a review from BeksOmega March 1, 2023 23:03
@github-actions github-actions bot added the PR: fix Fixes a bug label Mar 1, 2023
core/insertion_marker_manager.ts Outdated Show resolved Hide resolved
core/insertion_marker_manager.ts Outdated Show resolved Hide resolved
Comment on lines 571 to 578
if (this.firstMarker) {
eventUtils.disable();
try {
this.firstMarker.dispose();
} finally {
eventUtils.enable();
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oof, were we just eating memory before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assume the GC would have cleaned up after us eventually since the marker would have become unreachable, but you introduced this logic in #4184 to fix an issue so I'm carrying it forward.

@gonfunko gonfunko merged commit 3a7ac3b into google:develop Mar 1, 2023
@gonfunko gonfunko deleted the drag-optimization branch March 1, 2023 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: fix Fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Insertion Marker Manager creates unused marker blocks.
2 participants