missionpinball / mpf

Mission Pinball Framework: Open source software to run a real pinball machine.
http://missionpinball.org
MIT License
214 stars 142 forks source link

outline_width crashing mpf when using special characters. #1705

Open Pucksnok opened 1 year ago

Pucksnok commented 1 year ago

Hello. Been trying the new feature outline_width with my code. After some trial and error I think I know why it crash my MPF (v.0.56.x).

When I use special characters in my text it freeze/crash MPF with no error message in logging or in terminal, without special characters it works great.

Example to crash... excuse the formating.

- type: text
  text: Pokémon
  outline_width: 2

Example where it works... excuse formating.

- type: text
  text: Pokemon
  outline_width: 2
Pucksnok commented 1 year ago

Can also add if setting the outline_width too high it freeze as well, for example outline_width: 2 works perfect while outline_width: 8 freeze the kivy window, timers etc. still run in console.

toomanybrians commented 1 year ago

I wonder if this happens if the font you use does not include the special character? As for the outline_width, I don't really have a guess there.

For both of these, the code in MPF-MC is very simple, anything you set in a config is just passed on to Kivy (which is the Python multimedia interface MPF-MC uses). So troubleshooting this would be a Kivy issue and something to figure out with that project and their forums.

As an example, here are the only instances of "outline_width" in all of MPF-MC, in the file mpfmc/widgets/text.py:

    def _get_outline_width(self) -> Optional[int]:
        return self._label.outline_width

    def _set_outline_width(self, outline_width: Optional[int]) -> None:
        self._label.outline_width = outline_width

    outline_width = AliasProperty(_get_outline_width, _set_outline_width)

So really there's not much we can do at the MPF-MC level.

One option would be to update the documentation with a note that the outline width might crash if it gets too big? And then depending on what you figure out with the fonts and special characters, maybe a doc update there too?

Sorry we don't have a better answer!

Pucksnok commented 1 year ago

Thanks, I will try a bit with other fonts. I use impact that's in the fonts-folder in my machines folder.

Will do an update if/when I get some progress. Well try and do some update to documentation if it's the same with other fonts and I can get someone to replicate it with code.

Cheers.

Pucksnok commented 1 year ago

Just updating with what I find.

If I wait when it freeze instead of closing mpf/mpfmc I get a error message with (0xC0000028), seems I can find some stuff with it and this looks to be the issue..

_The workaround from #7914 works fine:

import os os.environ['KIVY_TEXT'] = 'pil'

The second working workaround is to update library:

venv\share\sdl2\bin\SDL2_ttf.dll

from 2.0.18 to latest one 2.20.1 https://github.com/libsdl-org/SDL_ttf/releases

Seems this bug was fixed starting from 2.19.2 (Fixed crash when loading fonts at certain sizes on Windows) SDLttf issue

https://github.com/kivy/kivy/issues/7914

https://github.com/kivy/kivy/issues/8108

I will try and install a nightly master edition of Kivy and see if it works, not sure mpf-mc allows it but can't hurt to try.

Pucksnok commented 1 year ago

I will also try this on my Linux machine, my guess it should work without issue there. I will report back on Sunday when I have the time to test.

toomanybrians commented 1 year ago

This looks really promising! (The update from SDL ttf 2.0.x to 2.20.x.) The way those get installed varies per platform, but it's definitely possible to update them. And also, yeah, you should be able to run with any version of Kivy. I've been using 2.1.0 in my MPF 0.57 dev branch which seems fine, so even moving to the latest release of 2.2.1 might help.