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

Error in plot /pdf(...): failed to load default encoding #10

Open
psychemedia opened this issue Sep 18, 2024 · 5 comments
Open

Error in plot /pdf(...): failed to load default encoding #10

psychemedia opened this issue Sep 18, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@psychemedia
Copy link

psychemedia commented Sep 18, 2024

I am trying to run a local version of webr via the JupyterLite (3.3) kernel in a self-contained package served usig flask and bundled using pyinstaller. It works well enough on a Mac, but on Windows I get an Error: Error in pdf(...): failed to load default encoding when I try a simple plot.

image

Any suggestions about workarounds / fixes much appreciated.

If I run:

Sys.getlocale()
localeToCharset()

On both Mac and Win I get: [1] "UTF-8" "ISO8859-1"

@psychemedia
Copy link
Author

psychemedia commented Sep 18, 2024

Encodings in: /vfs/usr/lib/R/library/grDevices/enc.js.metadata:

{"files":[{"filename":"/AdobeStd.enc","start":0,"end":2094},
{"filename":"/AdobeSym.enc","start":2094,"end":4608},
{"filename":"/CP1250.enc","start":4608,"end":6832},
{"filename":"/CP1251.enc","start":6832,"end":9221},
{"filename":"/CP1253.enc","start":9221,"end":11406},
{"filename":"/CP1257.enc","start":11406,"end":13653},
{"filename":"/Cyrillic.enc","start":13653,"end":16002},
{"filename":"/Greek.enc","start":16002,"end":18214},
{"filename":"/ISOLatin1.enc","start":18214,"end":20427},
{"filename":"/ISOLatin2.enc","start":20427,"end":22614},
{"filename":"/ISOLatin7.enc","start":22614,"end":24886},
{"filename":"/ISOLatin9.enc","start":24886,"end":27082},
{"filename":"/KOI8-R.enc","start":27082,"end":29372},
{"filename":"/KOI8-U.enc","start":29372,"end":31680},
{"filename":"/MacRoman.enc","start":31680,"end":33942}
{"filename":"/PDFDoc.enc","start":33942,"end":36149},
{"filename":"/TeXtext.enc","start":36149,"end":38240},
{"filename":"/WinAnsi.enc","start":38240,"end":40551}]
,"remote_package_size":40551}

Settings in webkernel.ts::setupEnvironment():

options(device = function(...){
        pdf(...)
        dev.control("enable")
      }, webr.plot.new = FALSE)

Using constructions of the form pdf(encoding="CP1250.enc", ...) have no effect other than changing the form of the error message (Error: Error in pdf(encoding = "CP1250.enc", ...): failed to load default encoding etc.).

@psychemedia
Copy link
Author

psychemedia commented Sep 20, 2024

Try with canvas? Notes on setting driver options to canvas here: https://docs.r-wasm.org/webr/latest/plotting.html

@psychemedia
Copy link
Author

Exploring:

@georgestagg
Copy link
Member

Could you post an image of the browser's network log from DevTools? Are there any downloading errors as you run the plot() command (as in the first example)?

Does setting the device option to the following instead work?

options(device = function(...){
    png(...)
    dev.control("enable")
 }, webr.plot.new = FALSE)

plot(1)

It seems strange that OS matters here. I wonder if there is some issue with line ending in the served VFS content.

@psychemedia
Copy link
Author

Ok - the above device option works - thanks for that tip...

There were no issues in the dev log otherwise, eg from the following in a new kernel:

image

So the encoding file is read but then there's some sort of mismatch presumably against the claimed default encoding and the encoding catalogue?

@georgestagg georgestagg added the bug Something isn't working label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants