-
-
Notifications
You must be signed in to change notification settings - Fork 223
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
Printing failed because the contentWindow
of the print iframe did not load
#384
Comments
Hello. Could you please give more details? What is the full error message? Also, what does your code look like? Thank you |
react_devtools_backend.js:2560 Printing failed because the |
Could you please share the code you use to print? I've not seen this error reported before. Also, what version of React are you using? |
@rohit9430 @137942170 could you please provide a code sample and let me know what version of React you're using, and what browser/version? |
IOS version: 14.7.1 import React, { useRef } from "react";
import { useReactToPrint } from "react-to-print";
const App = () => {
const componentRef = useRef();
const handlePrint = useReactToPrint({
content: () => componentRef.current,
});
return (
<div ref={componentRef}>
// content to be printed
</div>
<Button onClick={handlePrint}>
Print
</Button>
)
} The weird part is it works in regular safari, but if the site is opened from an app in a webview, say like slack, that's when it errors. |
Interesting. That's super helpful for helping me debug, thanks for the post. Not sure if it's something we can fix, but will try! |
I can confirm this issue as well. Our logs are filled with users trying to launch the print window from web views inside apps like Facebook and Instagram. They receive this error, This happens in both Android (Chrome) and iOS (Safari).
The print works fine if the website is opened normally in the browser. |
This is under active research, but at this time prospects are looking grim that we have any power here. I think this is completely in the hands of Google/Apple. Resources I've found so far:
I've also found this hard to properly debug. The simplest way for me to debug this currently is with the "WebView Browser Tester" on the Android Studio emulator. However, running the library's example code there does not produce the error seen in this thread, and instead the print is a no-op, which seems to be the intended behavior by the Chromium team for printing iframes currently unfortunately. Other resources I came across:
|
Further conversation with the Chromium team seems to confirm that WebView support for https://bugs.chromium.org/p/chromium/issues/detail?id=322303#c34 There are a few options here:
I think option 2 is the ideal, just need to figure out if it's possible, and if it is, how to do it |
Is there any update about the issue? |
Unfortunately we're at the mercy of Android here 😢 |
@tiffanytut0225 could you please make a working Codesandbox or similar replicating the problem ideally? It's hard to debug parts of your code |
The same code I provided works on Codesandbox. 😂 |
This error was just thrown in my application. The print works in:
Its a web app, and in Chromes fails... But this code of mine is a released feature, and nothing changed (maybe chrome version) |
@ricardo-fnd can you be more specific please? Desktop Chrome or mobile Chrome? Assuming mobile Chrome, Android or iOS? Also, did you use a WebView or did you actually open in Chrome? WebView is not Chrome |
@MatthewHerbst Desktop chrome. nothing more. its an nextjs app... this was working before |
@MatthewHerbst I found the bug. |
@MatthewHerbst also |
@MatthewHerbst suddenly its working again, without any change... I dont know what to tell you lol. probably some version mismatch |
Strange, but glad it's working! If it occurs again please let me know |
I have these problems:
|
Printing failed because the
contentWindow
of the print iframe did not loadThe text was updated successfully, but these errors were encountered: