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(missing-annotations): Fix annotations on zoom issue #701

Merged
merged 3 commits into from
Jul 24, 2023

Conversation

JChan106
Copy link
Contributor

@JChan106 JChan106 commented Jul 20, 2023

Due to changes in PDFjs v3.6.172, annotations would dissapear upon zooming in/out on the pdf. This is because the page elements that our annotation managers were referencing would be removed when zooming in/out. The textLayer pdfJS uses would not be removed however, which would make one of our managers not get cleaned up. In order to reinstantiate our managers, we need all managers to be cleaned up. Because of our current logic for adding managers, we need to make sure every manager is cleaned up when at least one manager is cleaned up. Which makes sense since the annotation managers are coupled together and cannot function correctly without the others.

Annotation Drawing mode
2023-07-19 23 46 18

Annotation Highlight mode
2023-07-19 23 52 06

@JChan106 JChan106 requested a review from a team as a code owner July 20, 2023 01:54
@JChan106 JChan106 requested a review from jstoffan July 20, 2023 01:54
managers.forEach(manager => {
if (!manager.exists(pageEl)) {
destroyManagers = true;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What if the third manager in the list doesn't exist but there are 6 managers. That means the first 2 won't get destroyed. Is that the behavior we want?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah my mistake, updated. Good catch.

@bfoxx1906 bfoxx1906 self-requested a review July 20, 2023 18:39
src/document/DocumentAnnotator.ts Show resolved Hide resolved
manager.destroy();
});
managers.clear();
destroyManagers = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if we don't reset the destroyManagers values here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be the same result, but I don't see any downsides to resetting the value since it should not be true anymore.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea it should have no effects but it's not needed though because the value won't be used again after that. Resetting it makes it seem like that value is relevant even after we clear the managers.

@bfoxx1906 bfoxx1906 self-requested a review July 20, 2023 18:53
@JChan106 JChan106 merged commit 6f66b54 into box:master Jul 24, 2023
@JChan106 JChan106 deleted the missing-annotations-issue branch July 24, 2023 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants