Skip to content

fix PDF rendering issue #70

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

fix PDF rendering issue #70

wants to merge 1 commit into from

Conversation

bryans99
Copy link

It appears that the visualization is prematurely notifying the PDF rendering that the visualization has completed rendering. This fix adds waits to make sure all promises have finished before calling done.

It appears that the visualization is prematurely notifying the PDF
rendering that the visualization has completed rendering. This fix
adds waits to make sure all promises have finished before calling
done.
@bryans99 bryans99 requested a review from a team as a code owner June 27, 2025 17:08
@bryans99 bryans99 requested review from Itzaprado and yesudeep and removed request for a team and Itzaprado June 27, 2025 17:08
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @bryans99, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a PDF rendering issue by ensuring that the visualization waits for all rendering promises to complete before notifying the PDF renderer that the process is done. This is achieved by making the buildReportTable function asynchronous and adding await calls to key rendering functions, as well as wrapping the call in a promise to handle errors.

Highlights

  • Asynchronous Rendering: The buildReportTable function is now asynchronous to ensure all rendering promises are resolved before proceeding.
  • Await Calls: Added await calls to removeStyles() and renderTable() to properly synchronize the rendering process.
  • Promise Handling: Wrapped the buildReportTable call in the update function with a .then() block to ensure done() is called after the table is built, and added a .catch() block to handle potential errors.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The code changes introduce waits to make sure all promises have finished before calling done, to address a PDF rendering issue. I've identified a potential bug where an animation-heavy function (addOverlay) is not being awaited, which could lead to the PDF rendering issue persisting. I've also recommended using .finally() to reduce code duplication when signaling completion.

@@ -527,7 +527,7 @@ const buildReportTable = function (
);
};

renderTable().then(() => {
await renderTable().then(() => {

Choose a reason for hiding this comment

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

high

The addOverlay() call on line 534 within this then block is not awaited. Since addOverlay performs animations, not awaiting it means buildReportTable will resolve and done() will be called before the animations are complete. This likely means the PDF rendering issue will persist. To fix this, you should await addOverlay().

  await renderTable();

Copy link
Author

Choose a reason for hiding this comment

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

The animate custom theme should NOT be used if the visualization is rendered. Thats a larger change

@@ -42,7 +42,7 @@ const buildReportTable = function (
const chartCentreX = bounds.x + bounds.width / 2;
const chartCentreY = bounds.y + bounds.height / 2;

removeStyles().then(() => {
await removeStyles().then(() => {

Choose a reason for hiding this comment

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

medium

Using await with .then() is an anti-pattern1 as it mixes two different asynchronous handling styles. Since buildReportTable is an async function, it would be more idiomatic and readable to use await directly.

  await removeStyles();

Style Guide References

Footnotes

  1. Avoid mixing await with .then() for asynchronous operations. (link)

Copy link
Author

Choose a reason for hiding this comment

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

Agreed but I did not want to refactor that much code. I'm happy to let the content team do more work on this

Comment on lines +642 to +653
buildReportTable(config, dataTable, updateColumnOrder, element)
.then(() => {
// DEBUG OUTPUT AND DONE
// console.log('dataTable', dataTable)
// console.log('container', document.getElementById('visContainer').parentNode)

done();
done();
})
.catch(error => {
console.error(error);
done();
});

Choose a reason for hiding this comment

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

medium

To avoid repeating the done() call in both the success and error paths, you could use .finally()1. This would make the code slightly cleaner and more maintainable by ensuring done() is always called, regardless of the outcome.

buildReportTable(config, dataTable, updateColumnOrder, element)
  .then(() => {
    // DEBUG OUTPUT AND DONE
    // console.log('dataTable', dataTable)
    // console.log('container', document.getElementById('visContainer').parentNode)

  })
  .catch(error => {
    console.error(error);
  })
  .finally(() => {
    done();
  });

Style Guide References

Footnotes

  1. Use .finally() to avoid repeating code in both the success and error paths. (link)

Choose a reason for hiding this comment

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

That's a pretty good suggestion

Copy link
Author

Choose a reason for hiding this comment

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

I thought about it but I could not be arsed to do it

// console.log('container', document.getElementById('visContainer').parentNode)
buildReportTable(config, dataTable, updateColumnOrder, element)
.then(() => {
// DEBUG OUTPUT AND DONE

Choose a reason for hiding this comment

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

Are you intending to keep these comments in the code?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, it appears to be to aid debubugging

@bryans99
Copy link
Author

A ticket will be assigned to the content team regarding this. I've done some cursory testing on this and the vis still works. Feel free to take this over or create a new PR base upon it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants