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

[Bugfix] Entering image entropy via long click raises PIL Exception #453

Merged
merged 1 commit into from
Aug 24, 2023

Conversation

kdmukai
Copy link
Contributor

@kdmukai kdmukai commented Aug 23, 2023

fixes #450

The problem

Prior to this PR, the frame is None check did not affect later attempts to paste that frame into the Renderer upon final image click.

Note: When the camera first starts up, it can initially return frame == None for a few cycles.

If the user enters image entropy (Tools -> New seed) via a long click (click-and-hold), they enter a race condition with the camera: will the camera return a valid frame before the long click repeat triggers the final image logic?

Resolution

This PR:

  • reorganizes the if checks in the loop
  • adds stricter handling when frame is None
    • adds a very short time.sleep() to give the camera more time to warm up.

Misc

  • Slightly more efficient BACK condition to exit the loop (no point in drawing the next preview frame if we're canceling).
  • Minor edit to preserve newer preview frames after max_entropy_frames has been reached; now cycles older frames out in order to keep writing the new preview frames. No discernible impact on performance, though I didn't attempt to measure before/after framerate.

@jdlcdl
Copy link

jdlcdl commented Aug 23, 2023

as of 91b0206, which is just one commit ahead of Nicks merges last night (2244509),
and assuming that cleanup of imports (Keyboard, TextEntryDisplay, BaseTopNavScreen, FormattedAddress, and QR) is just tidying of unused imports...

ACK tested on raspi-os and on seedsigner-os.

The long press was religiously causing this exception, at least all the way back to 0.5.1-EXP, and a short press was avoiding it. Now, a long press will NOT raise any exception... but I know I pressed long because the captured frame is the next step.

@newtonick
Copy link
Collaborator

ACK and tested

@newtonick newtonick merged commit 2a7843f into SeedSigner:dev Aug 24, 2023
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

Successfully merging this pull request may close these issues.

Creating seed via image entropy w/ another seed loaded raises exception
3 participants