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

“Failed to decode data” error #207

Open
xplosionmind opened this issue Jun 26, 2024 · 6 comments
Open

“Failed to decode data” error #207

xplosionmind opened this issue Jun 26, 2024 · 6 comments

Comments

@xplosionmind
Copy link

Using Frog 1.5.1 installed from Flatpak on Fedora 40 using GNOME and Wayland.

Logs

flatpak run com.github.tenderowl.frog 

** (python:2): WARNING **: 13:09:18.058: expected enumeration type void, but got PyGLibOptionArg instead
2024-06-26 13:09:18.063 | DEBUG    | frog.widgets.language_popover:__init__:69 - active-language
2024-06-26 13:09:18.086 | DEBUG    | frog.language_manager:active_language:208 - Active language set to <LanguageItem: Italian, ita>
/app/lib/python3.11/site-packages/frog/window.py:84: Warning: g_variant_type_checked_: assertion 'g_variant_type_string_is_valid (type_string)' failed
  self.install_action("window.share", "provider", self._on_share)
/app/lib/python3.11/site-packages/frog/window.py:84: Warning: g_variant_type_copy: assertion 'g_variant_type_check (type)' failed
  self.install_action("window.share", "provider", self._on_share)
2024-06-26 13:09:21.618 | DEBUG    | frog.main:on_settings_changed:145 - SETTINGS: %s changed
2024-06-26 13:09:21.628 | DEBUG    | frog.services.screenshot_service:decode_image:117 - Decoding with ita+eng language.
2024-06-26 13:09:21.666 | DEBUG    | frog.services.screenshot_service:decode_image:140 - ERROR: 
@teamcons
Copy link

Exact same issue, for english, when selecting from an area. Same output. Same system (albeit, Silverblue)

@pthr
Copy link

pthr commented Sep 17, 2024

I too encountered this issue; Frog 1.5.1, GNOME 47 on Wayland, Arch.
In services/screenshot_service.py, at the beginning of decode_image I added:

# replace %xx escapes with their single-character equivalent 
if isinstance(file, str):
    from urllib.parse import urlparse, unquote
    file = unquote(urlparse(file).path)

...and with that the issue disappeared.

Apparently decode_image receives a path with '%xx escapes', and apparently Image.open fails to interpret these.

@DaPigGuy
Copy link
Contributor

I too encountered this issue; Frog 1.5.1, GNOME 47 on Wayland, Arch. In services/screenshot_service.py, at the beginning of decode_image I added:

# replace %xx escapes with their single-character equivalent 
if isinstance(file, str):
    from urllib.parse import urlparse, unquote
    file = unquote(urlparse(file).path)

...and with that the issue disappeared.

Apparently decode_image receives a path with '%xx escapes', and apparently Image.open fails to interpret these.

This was fixed in Frog 1.5.2, released 3 weeks ago. Make sure to update your apps!

This issue (and #98) should be closed @amka

@xplosionmind
Copy link
Author

I am using v1.5.2, and I am still getting the same error:

flatpak run com.github.tenderowl.frog 

** (python:2): WARNING **: 10:38:37.824: expected enumeration type void, but got PyGLibOptionArg instead
2024-09-28 10:38:37.832 | DEBUG    | frog.widgets.language_popover:__init__:69 - active-language
2024-09-28 10:38:37.867 | DEBUG    | frog.language_manager:active_language:208 - Active language set to <LanguageItem: Italian, ita>
/app/lib/python3.11/site-packages/frog/window.py:84: Warning: g_variant_type_checked_: assertion 'g_variant_type_string_is_valid (type_string)' failed
  self.install_action("window.share", "provider", self._on_share)
/app/lib/python3.11/site-packages/frog/window.py:84: Warning: g_variant_type_copy: assertion 'g_variant_type_check (type)' failed
  self.install_action("window.share", "provider", self._on_share)
2024-09-28 10:38:41.757 | DEBUG    | frog.main:on_settings_changed:145 - SETTINGS: %s changed
2024-09-28 10:38:41.768 | DEBUG    | frog.services.screenshot_service:decode_image:118 - Decoding with ita+eng language.
2024-09-28 10:38:41.847 | DEBUG    | frog.services.screenshot_service:decode_image:141 - ERROR: 
2024-09-28 10:38:50.565 | DEBUG    | frog.main:on_settings_changed:145 - SETTINGS: %s changed
2024-09-28 10:38:50.576 | DEBUG    | frog.services.screenshot_service:decode_image:118 - Decoding with ita+eng language.
2024-09-28 10:38:50.889 | DEBUG    | frog.services.screenshot_service:decode_image:141 - ERROR: 
2024-09-28 10:38:54.353 | DEBUG    | frog.main:on_settings_changed:145 - SETTINGS: %s changed
2024-09-28 10:38:54.363 | DEBUG    | frog.main:on_settings_changed:145 - SETTINGS: %s changed

@DaPigGuy
Copy link
Contributor

DaPigGuy commented Sep 28, 2024

@xplosionmind Unfortunately, Frog is not correctly logging the error, and the warning above is unrelated. I am also unable to reproduce the issue on Fedora 41/GNOME/Wayland + Flatpak. Could you clone the repo, apply two simple changes, & then run it so we could get actual info on what's wrong?

  1. Replace line 141 of frog/services/screenshot_service.py with logging.exception("ERROR") which will produce a stacktace
  2. Add an import logging

I would recommend using GNOME Builder which will make editing & running very easy.

@xplosionmind
Copy link
Author

Sorry for the late reply, @DaPigGuy!

I followed the steps that you told me, and unfortunately I can’t reproduce the bug either… It works with all the three options to get an image to extract text from! Maybe the log could shine some light on the matter:

Application started at 01:06:27 PM
2024-11-19 13:06:28.517 | INFO     | frog.main:ensure_installation_id:136 - No installation id was found. Generating a new one.

** (python:2): WARNING **: 13:06:28.551: expected enumeration type void, but got PyGLibOptionArg instead
2024-11-19 13:06:28.555 | DEBUG    | frog.widgets.language_popover:__init__:69 - active-language
2024-11-19 13:06:28.573 | DEBUG    | frog.language_manager:active_language:208 - Active language set to <LanguageItem: English, eng>
/app/lib/python3.12/site-packages/frog/window.py:84: Warning: g_variant_type_checked_: assertion 'g_variant_type_string_is_valid (type_string)' failed
  self.install_action("window.share", "provider", self._on_share)
/app/lib/python3.12/site-packages/frog/window.py:84: Warning: g_variant_type_copy: assertion 'g_variant_type_check (type)' failed
  self.install_action("window.share", "provider", self._on_share)
2024-11-19 13:06:52.550 | DEBUG    | frog.main:on_settings_changed:145 - SETTINGS: %s changed
2024-11-19 13:06:59.973 | DEBUG    | frog.services.screenshot_service:decode_image:119 - Decoding with eng+eng language.
2024-11-19 13:07:00.289 | DEBUG    | frog.services.screenshot_service:decode_image:148 - Removing /run/user/1000/doc/b354d02a/Screenshot From 2024-11-19 13-06-59.png
2024-11-19 13:07:00.290 | DEBUG    | frog.services.screenshot_service:decode_image:151 - Error deleting /run/user/1000/doc/b354d02a/Screenshot From 2024-11-19 13-06-59.png: [Errno 13] Permission denied: '/run/user/1000/doc/b354d02a/Screenshot From 2024-11-19 13-06-59.png'
2024-11-19 13:07:00.290 | DEBUG    | frog.services.screenshot_service:decode_image:154 - Extracted successfully

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

4 participants