Andereoo/TkinterWeb

Application crashing with set_persemode "xhtml"

tschertel opened this issue ยท 11 comments

Hi there.
I'm writing an epub reader using ebooklib and TkinterWeb to improve my python skills.
I have a ListBox to show epub's chapters and when I click one of the items from this ListBox, the app shows the chapter's content in the HTMLFrame.
As ebooklib shows document's type as "application/xhtml+xml", I've decided to change parse mode to "xhtml". But now the app crashes when it tries to show some chapter's content. It works flawless using the default parse mode.
It always happens with the same chapters in the same books. I've opened these books using Calibre's ebook editor and Sigil. But I just can't see any difference from other chapters and books.
Is there a way to debug this error? Is there some kind of "verbose" feature to find what's happening?

Thanks.

Hi!

That seems to be a bug with the underlying Tkhtml HTML engine. It hasn't been updated in many years and doesn't handle some types of more modern HTML and CSS declarations well. It also is not particularly good at throwing errors. I would strongly recommend leaving the parse mode as xml because it makes Tkhtml less picky.

That being said, if you could upload the HTML code that causes the error, I might be able to try and pinpoint the problem. Thanks!

Hi, sorry for taking long to reply.
This is one of the files that makes my app crash. I added the CSS files too.
app_crash.zip

Thank you very much.

Thanks for the files. I can't seem to reproduce the issue. I'll close this for now, because TkinterWeb seems to work fine using the default parse mode, but I will let you know if I find anything moving forward. Regarding the verbose feature, if you are using the latest version of TkinterWeb, open TkinterWeb's bindings.py file and uncomment the lines that read:

if "logcmd" not in kwargs:
        kwargs["logcmd"] = tkhtml_notifier

Beware that this will make the widget very slow. Feel free to let me know what the output is!

I did as you told me.
I enabled the logs, piped the output to a file, then just opened a file and clicked on the ebook's chapter to make my app crash. But it didn't. Everything seems to work fine with those two uncommented lines.
This is the log file. Until line 531 is all about the default output.
After that, you can find the actual log regarding the problematic chapter.
error.log

That's pretty weird. Could you please confirm that commenting out the last two lines in the latest TkinterWeb version causes crashes?

Yes.
With both lines commented and with parse mode set to "xhtml" my app crashes.

Maybe it's just a coincidence or something from my head, but looks like all crashing pages have (big?) images.

image

image

Does the app still crash if you disable images or remove the images from the code?

I've just tested and everything works flawless with enable_images(False) and set_parsemode("xhtml").
It could be something related to the way I'm using TkinterWeb, because I still need to find a way to show the images.
If you want to try it, you can find my app here. Just go easy on me. I'm still a beginner. ๐Ÿ˜„

edit: just saw I also have ignore_invalid_images(False).

Do you have a sample book that is causing trouble?

Hi @Andereoo
I have tested other books and now only one book crashes the app. It used to be about 3 books (that I knew of), and I don't think it's worth pursuing it.
I'm sorry for the trouble, and thanks for everything.

No worries! Sorry I couldn't be more helpful here. I think at this point it's best we simply leave the parse mode as xml, but if you notice anything else or if you have similar issues with xml please feel free to reach out.