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

Painter not active #42

Open
bitmage opened this issue Sep 19, 2022 · 4 comments
Open

Painter not active #42

bitmage opened this issue Sep 19, 2022 · 4 comments

Comments

@bitmage
Copy link

bitmage commented Sep 19, 2022

When I try to export a file I get:

QPainter::begin(): Returned false
QPainter::setWorldTransform: Painter not active
QPainter::setOpacity: Painter not active
QPainter::restore: Unbalanced save/restore
QPainter::end: Painter not active, aborted

...and many pages of the same messages repeated.

I'm on Manjaro Linux. Using the default config, just changed the source "host" and export "default_dir". The browsing UI seems to connect to the device and work well, it's just export that has a problem. The first export directory I tried had a space in it. I then tried a directory without a space. No change.

Any thoughts? Could it be missing a dependency?

@bitmage
Copy link
Author

bitmage commented Sep 19, 2022

More info on dependencies. They seem to be all present, installed by pip. Additionally I installed simplification just in case. No change in behavior.

Name: requests
Version: 2.28.1
Summary: Python HTTP for Humans.
Required-by: CacheControl, Remy

Name: sip
Version: 6.6.2
Summary: A Python bindings generator for C/C++ libraries
Required-by: Remy

Name: arrow
Version: 1.2.3
Summary: Better dates & times for Python
Required-by: Remy

Name: paramiko
Version: 2.11.0
Summary: SSH2 protocol library
Required-by: Remy

Name: PyPDF2
Version: 1.28.4
Summary: A pure-python PDF library capable of splitting, merging, cropping, and transforming PDF files
Required-by: Remy

Name: PyQt5
Version: 5.15.7
Summary: Python bindings for the Qt cross platform application toolkit
Required-by: Remy

Name: PyMuPDF
Version: 1.20.2
Summary: Python bindings for the PDF toolkit and renderer MuPDF
Required-by:

Name: simplification
Version: 0.6.1
Summary: Fast linestring simplification using RDP or Visvalingam-Whyatt and a Rust binary
Required-by:

@bordaigorl
Copy link
Owner

QPainter::begin() should not be returning false...it usually means the path that was given for the PDF cannot be opened with writing permissions.
Could it be a permissions problem?

@bitmage
Copy link
Author

bitmage commented Sep 20, 2022

Saving to ~/Trees.pdf fails in the same way. It's running under my user, so it shouldn't be a permissions issue.

I expanded the tilde to /home/bitmage/Trees.pdf and I get a different error now:

qt.qpa.xcb: QXcbConnection: XCB error: 3 (BadWindow), sequence: 6517, resource id: 18017478, major code: 40 (TranslateCoords), minor code: 0

It hangs for a minute or two and then starts drawing the tree on the page. Success! So it looks like the problem is that it was unable to expand the tilde for my home directory.

While I was experimenting with other options, I found this script written in Go which is able to perform the translations to PDF orders of magnitude faster. It converts about 250 notebooks that I have in a few seconds. I know it's probably not fun to do FFI but it might be worth it to get this kind of speedup.

@bordaigorl
Copy link
Owner

Thanks for the feedback!
I'll make a note about tilde expansion (and better error messages).

Regarding the rendering time:

  • what many other scripts do is much more basic in terms of accuracy than what Remy attempts. There are some settings that help, like eraser_mode and pencil_resolution (see the readme)
  • Remy uses the Qt PDF writer which is not very fast, but allows to produce a PDF from the same code that produces the preview
  • I am planning to use PyMuPdf for merging the scribbles and the original PDFs which is faster and more accurate, but I cannot promise it will happen

One thing to check is whether the preview window also takes a long time to render: in that case there's something in that particular drawing that is difficult to handle.

FFI sounds like an overkill. One thing I could consider is to allow executing arbitrary scripts over a document, so that Remy takes care of downloading the appropriate files and feeding the UIDs to the script in question.

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

No branches or pull requests

2 participants