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

[Bug]: Cannot embed PDF in iframe when accessing local files via protocol.registerFileProtocol(). #33094

Closed
3 tasks done
george-thomas-hill opened this issue Feb 27, 2022 · 8 comments

Comments

@george-thomas-hill
Copy link

Preflight Checklist

Electron Version

17.1.0

What operating system are you using?

Other Linux

Operating System Version

Kubuntu 21.04

What arch are you using?

x64

Last Known Working Electron version

n/a

Expected Behavior

I expect to be able to display a PDF (or any other arbitrary local file) by embedding it in an iframe inside a BrowserWindow instance.

I expect to be able to access the local file by using protocol.registerFileProtocol() as described here: #23393

Actual Behavior

When I use the minimal test case available here . . .

https://github.com/george-thomas-hill/demo-electron-problem-embeding-pdf

. . . the PDF does not display.

My renderer process displays an empty iframe.

In my console, I get the message:

(node:2797438) electron: Failed to load URL: protocol://secretString/707861804 with error: ERR_BLOCKED_BY_CLIENT

Testcase Gist URL

No response

Additional Information

This might be related to the following issue: #28407

However, that issue's given workaround isn't available to me, because I'm using electron-forge and webpack, so my main process needs to have mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY); I don't see a way to use loadURL('app://./index.html');.

I am able to display arbitrary files by using the following in app.jsx:

                <webview
                    src={useSrc}
                >
                </webview>

However, the Electron documentation advises against using <webview> elements, i.e. here: https://www.electronjs.org/docs/latest/api/webview-tag

I have also tried using the following in app.jsx:

                <embed
                    type="application/pdf"
                    src={useSrc}
                >
                </embed>

However, that crashes my app.

I believe that this constitutes a bug, and I hope it can be fixed.

Alternatively, I would be grateful for any advice regarding how to securely use <webview> tags (or some other work-around).

Thank you.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 5, 2022

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label Oct 5, 2022
@george-thomas-hill
Copy link
Author

bump

@github-actions github-actions bot removed the stale label Oct 16, 2022
@george-thomas-hill
Copy link
Author

Update:

I'm still finding (in Electron 21.2.0) that loading a PDF in an iFrame fails to display the PDF, and loading a PDF in a webview crashes Electron.

Here's an Electron Fiddle gist that demonstrates this:

https://gist.github.com/george-thomas-hill/c3179e6eddeb1a2715201a20dbf95015

@shotor
Copy link

shotor commented Nov 18, 2022

I'm seeing the same issues with no workaround. Using Electron 21.3.0

iframe, embed, object => grey box - network tab shows file was requested correctly
webview => 0x0 element in dom - no crash

I get this error in the console:

[70442:1118/152356.989338:ERROR:bad_message.cc(29)] Terminating renderer for bad IPC message, reason 1

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label Feb 17, 2023
@github-actions
Copy link
Contributor

This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 20, 2023
@0kuang
Copy link

0kuang commented May 21, 2023

I'm seeing the same issues with no workaround. Using Electron 21.3.0

iframe, embed, object => grey box - network tab shows file was requested correctly webview => 0x0 element in dom - no crash

I get this error in the console:

[70442:1118/152356.989338:ERROR:bad_message.cc(29)] Terminating renderer for bad IPC message, reason 1

+1; I have the same problem in 24.1.3

@Skywalker13
Copy link

Same problem with electron 26...

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

No branches or pull requests

4 participants