Skip to content

feat(Canvas): add support for displaying output in Jupyter Notebook#60

Merged
DjDeveloperr merged 2 commits intomainfrom
display-support
Oct 7, 2023
Merged

feat(Canvas): add support for displaying output in Jupyter Notebook#60
DjDeveloperr merged 2 commits intomainfrom
display-support

Conversation

@DjDeveloperr
Copy link
Copy Markdown
Owner

No description provided.

@rgbkrk
Copy link
Copy Markdown

rgbkrk commented Sep 21, 2023

Giving your branch a spin now to see if I can find the issue you mentioned on discord.

After getting everything to build I've gotten to the same issue you ran into. I even tried defining the Symbol.for(Jupyter.display) earlier in the code and referencing that directly.

image

@rgbkrk
Copy link
Copy Markdown

rgbkrk commented Sep 21, 2023

Well I got it to work and it must be a TypeScript or Deno quirk. If you bind it in the constructor then the Deno kernel picks it up:

  constructor(width: number, height: number, gpu = false) {
    this[$display] = this[$display].bind(this);
image

👀 Something weird with Deno/Rust picking up the available function on this class @bartlomieju. We gotta find a minimal version that has this odd behavior.

@bartlomieju
Copy link
Copy Markdown

Could you point me which one is not working here? Is it canvas.ts or svgcanvas.ts?

@DjDeveloperr
Copy link
Copy Markdown
Owner Author

Could you point me which one is not working here? Is it canvas.ts or svgcanvas.ts?

@bartlomieju it's canvas.ts

@bartlomieju
Copy link
Copy Markdown

Thanks, I'll try to take a look ASAP.

@bartlomieju
Copy link
Copy Markdown

I just tried this and I got:
Screenshot 2023-09-23 at 10 22 58

I think this is related to denoland/deno#20528

@bartlomieju
Copy link
Copy Markdown

So the underlying issue is that this error is raised:

TypeError: Cannot read properties of undefined (reading 'encode')\n    at [Jupyter.display] (file:///Users/ib/dev/skia_canvas/src/canvas.ts:215:38)\n    at <anonymous>:4:33

However I don't yet understand why that's the case. The transpiled output looks correct and AFAIK this should be the class intance in this case. I will consult with the team and get back to you.

@rgbkrk
Copy link
Copy Markdown

rgbkrk commented Oct 7, 2023

The bug causing it to not render properly has been fixed: denoland/deno#20789

image

I had to jump to denoland/deno@cbddf57 to make it work though because deno main can't load this module right now (#61).

@DjDeveloperr
Copy link
Copy Markdown
Owner Author

DjDeveloperr commented Oct 7, 2023

Awesome fix @rgbkrk - I'll cut a release once that fix makes it to stable!

@DjDeveloperr DjDeveloperr merged commit a6a2219 into main Oct 7, 2023
@DjDeveloperr DjDeveloperr deleted the display-support branch October 7, 2023 04:29
@rgbkrk
Copy link
Copy Markdown

rgbkrk commented Oct 9, 2023

The fix for ffi is on main.

@rgbkrk
Copy link
Copy Markdown

rgbkrk commented Oct 13, 2023

1.37.2 is out with the fix, feel free to ship 🚢

@DjDeveloperr
Copy link
Copy Markdown
Owner Author

I've released 0.5.5:

image

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