Skip to content

Fall back to GetCanvas() when the task framebuffer is unavailable#24

Open
wonderbeel wants to merge 3 commits into
simmsb:masterfrom
wonderbeel:emulator-getcanvas-fallback
Open

Fall back to GetCanvas() when the task framebuffer is unavailable#24
wonderbeel wants to merge 3 commits into
simmsb:masterfrom
wonderbeel:emulator-getcanvas-fallback

Conversation

@wonderbeel

Copy link
Copy Markdown

Was playing with your bindings yesterday night and noticed that my hello world app was working fine on my physical devices but panicking on the SDK emulator. Pocked at it with help from claude and found that on the emulator the framebuffer task is always null and that it is causing the panic. Let me know if the patch is fine (rust novice, I am starting to use it now to play on my pocketbook) or if you would prefer a different approach to make the emulator work

GetCurrentTask()/GetTaskFramebuffer() are only wired up on-device. In the
desktop SDK emulator GetCurrentTask() returns -1 and the task framebuffer is
null, so Screen::new() panics before anything is drawn.

Fall back to the global canvas (GetCanvas) -- the same icanvas_s, populated in
both environments. GetTaskFramebufferInfo is likewise task-only, so skip it on
the emulator instead of unwrapping a null pointer.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ihrfv

ihrfv commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

@wonderbeel, hey, I was wondering how you did the SDK emulator?

@wonderbeel

Copy link
Copy Markdown
Author

@ihrfv I used the one included in the SDK (you can find the last one here https://github.com/Sean-on-Git/PocketBook-SDK I found it on mobile read), I am on vacation right now so I don't have the full script at hand but it isn't too difficult to start it in a Debian host.

There is also this full emulator https://codeberg.org/datyoma/pbemu that I found on mobileread that completely emulates a device (it loads a firmware and spin it up with qemu and podman) and here the the framebuffer issue didn't happen, I guess that it was indeed a quirk of the SDK emulator (it doesn't emulate the full device so probably there is some discrepancy under the hood and with stricter checks you find it while it slips undetected in inkview itself).

@simmsb simmsb left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heya, thanks for adding this :)

I can't really remember why I have it fetch the framebuffer by using GetTaskFrameBuffer as opposed to just GetCanvas, if I find time I'll try having the library always use GetCanvas.

For a small change like this that is easily testable I don't have a problem with it being LLM generated.

Comment thread inkview/src/screen.rs Outdated
@wonderbeel

Copy link
Copy Markdown
Author

Applied the comment, thank you for double checking :).

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.

3 participants