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

HASS: libturbojpeg switch to libjpeg-turbo #1063

Closed
H3mul opened this issue Jul 15, 2024 · 4 comments
Closed

HASS: libturbojpeg switch to libjpeg-turbo #1063

H3mul opened this issue Jul 15, 2024 · 4 comments

Comments

@H3mul
Copy link
Contributor

H3mul commented Jul 15, 2024

Source:
home-assistant/docker#313

Currently, (using libturbojpeg), HASS can't seem to find libturbojpeg when using a camera entity:

2024-07-15 15:40:01.067 ERROR (MainThread) [homeassistant.components.camera.img_util] Error loading libturbojpeg; Camera snapshot performance will be sub-optimal
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/homeassistant/components/camera/img_util.py", line 98, in __init__
    TurboJPEGSingleton.__instance = TurboJPEG()
                                    ^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/turbojpeg.py", line 298, in __init__
    self.__find_turbojpeg() if lib_path is None else lib_path)
    ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/turbojpeg.py", line 928, in __find_turbojpeg
    raise RuntimeError(
RuntimeError: Unable to locate turbojpeg library automatically. You may specify the turbojpeg library path manually.
e.g. jpeg = TurboJPEG(lib_path)
@onedr0p
Copy link
Owner

onedr0p commented Jul 16, 2024

Already reported here #988. As I mentioned I'm not sure what the fix could be.

H3mul added a commit to H3mul/homelab-k3s-flux that referenced this issue Jul 16, 2024
@H3mul
Copy link
Contributor Author

H3mul commented Jul 16, 2024

Sorry for the duplicate, I misunderstood the upstream issue. Thanks for the link

Did a bit of digging, PyTurboJPEG just doesn't look in the location of the alpine package.

Short term fix: add LD_LIBRARY_PATH=/usr/lib env for HASS container
Long term fix: lilohuang/PyTurboJPEG#79

No fix from this repo required

@H3mul H3mul closed this as completed Jul 16, 2024
@H3mul
Copy link
Contributor Author

H3mul commented Jul 16, 2024

Small followup - found another alternative while chasing a different lib issue

Alpine linux causes problems with the python ctypes.utils.find_library() function, which many packages use. Eg, HASS also can't find libpcap for the same reason

find_library() attempts to use several tools, the one that works in Alpine Linux seems to be ld, it includes /usr/lib by default. But it only finds libraries symlinked to /usr/lib/*.so, which ONLY happens in -dev packages

Basically, if we add binutils for ld and -dev versions of lib packages for the symlink, LD_LIBRARY_PATH=/usr/lib is not necessary.

quick diff that fixes missing libturbojpeg and libpcap:

diff --git a/Dockerfile.onedr0p b/Dockerfile
index 36525de..43d9ca7 100644
--- a/Dockerfile.onedr0p
+++ b/Dockerfile
@@ -24,6 +24,7 @@ WORKDIR /app
 RUN \
     apk add --no-cache \
         bash \
+        binutils \
         bluez \
         bluez-deprecated \
         bluez-libs \
@@ -36,7 +37,8 @@ RUN \
         git \
         jq \
         libcap \
-        libturbojpeg \
+        libjpeg-turbo-dev \
+        libpcap-dev \
         libstdc++ \
         libxslt \
         mariadb-connector-c \

@onedr0p
Copy link
Owner

onedr0p commented Jul 16, 2024

Sounds good... Feel free to open a PR.

H3mul added a commit to H3mul/containers-onedr0p that referenced this issue Jul 18, 2024
onedr0p pushed a commit that referenced this issue Jul 18, 2024
* Fix hass library finding (libpcap and libturbojpeg)

Context:
#1063

* Fix hass non-root ping (needed by icmp component to function properly after 2024.3.0)
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