Skip to content
New issue

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

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

Already on GitHub? # to your account

Window getting unresponsive even after using webworker for pdf rendering #1933

Open
4 tasks done
Harshsharma916 opened this issue Jan 16, 2025 · 1 comment
Open
4 tasks done
Labels
bug Something isn't working

Comments

@Harshsharma916
Copy link

Before you start - checklist

  • I followed instructions in documentation written for my React-PDF version
  • I have checked if this bug is not already reported
  • I have checked if an issue is not listed in Known issues
  • If I have a problem with PDF rendering, I checked if my PDF renders properly in PDF.js demo

Description

I am using usePdf to render my react-pdf code, I have a wrapper like -

{...imports}
import '@react-pdf-viewer/core/lib/styles/index.css';
const ReportWebWorkerWrapper = ({ children, dependencies }) => {
  const [instance, update] = usePDF({
    document: children,
  });
  useEffect(() => {
    update({
      document: children,
    });
  }, [...dependencies]);
  if (instance?.error) {
    return <div>Something went wrong</div>;
  }
  return (
    <div
      style={{
        border: '1px solid rgba(0, 0, 0, 0.3)',
        height: '750px',
      }}
    >
      {instance?.loading ? (
        <div>Loading...</div>
      ) : (
        <Viewer
          fileUrl={instance?.url === null ? '' : instance?.url}
          renderError={(err) => {
            console.log(err);
          }}
        />
      )}
    </div>
  );
};

export default ReportWebWorkerWrapper;

And i am trying to render the following code that makes my webpage unresponsive -

const renderReport = () => {
return <Document>
<Page>
<>
          <ReportComponents.RenderTests
            testItem={testItem}
            reportSettings={reportSettings}
            testData={billingDetails?.testData}
            packages={packages}
            depIds={depIds}
            doctors={doctors}
            separateTest={separateTest}
            barCodeImages={barCodeImages}
            patientDetails={patientDetails}
            isTestMacData={isTestMacData}
          />
          <ReportComponents.SignComponent
            test={testItem.test}
            reportEnd={reportEnd}
            doctors={doctors}
            departmentEnd={departmentEnd}
            reportSettings={reportSettings}
          />
          {testItem?.test?.shouldShowLogo && (
            <ReportComponents.Logo reportSettings={reportSettings} />
          )}
        </>
</Page>
</Document>
}

[SmartReport.zip](https://github.com/user-attachments/files/18442303/SmartReport.zip)

Steps to reproduce

I have attached the code rendering the particular pdf
Go to SmartReport
import from SmartReport index.js
Render it inside ReportWebWorkerWrapper

Expected behavior

The expected behaviour is to render the pdf with table and if an error occurs the window should not become unresponsive but onRenderError in Viewer should give me something.

Actual behavior

The window is becoming unresponsive and no sign of error on console or onRenderError

Additional information

No response

Environment

  • Browser (if applicable): Chrome:
  • **React-PDF versions - **:
  • "@react-pdf-viewer/core": "^3.11.0",
    "@react-pdf/image": "^2.2.2",
    "@react-pdf/layout": "^3.6.4",
    "@react-pdf/pdfkit": "^3.1.2",
    "@react-pdf/renderer": "3.1.6",
    "@react-pdf/textkit": "^4.3.0",
  • Bundler name and version (if applicable):
@Harshsharma916 Harshsharma916 added the bug Something isn't working label Jan 16, 2025
@Harshsharma916
Copy link
Author

And if possible I would request for a quick gmeet because I guess I messed up explaining the issue clearly but i really need help!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant