Skip to content

fix(jupyter-widget): render layers with extensions from unloaded custom libraries - #10764

Merged
chrisgervang merged 3 commits into
masterfrom
chr/jupyter-widget-custom-extensions
Oct 1, 2026
Merged

chrisgervang merged 3 commits into
masterfrom
chr/jupyter-widget-custom-extensions

Conversation

@chrisgervang

@chrisgervang chrisgervang commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Background

Custom libraries load after the widget converts the deck JSON. A layer whose own @@type comes from a custom library converts to null and is added once the library loads. A built-in layer that uses a custom-library extension, such as extensions: [{'@@type': 'ZoomOpacityExtension'}], instead converts with extensions: [null]. Constructing that layer throws, createDeck fails, and the map stays blank. With the published 9.4.0 widget, pydeck to_html output using a deck.gl-community extension renders nothing.

Change List

  • create-deck.js: when conversion throws and custom libraries are pending, convertInitialJson converts each layer and widget separately. Only the ones that cannot be converted yet are left out of the first render.
  • Once the libraries load, the deferred layers and widgets are added. Any that still cannot be converted go to onError instead of hiding the others or throwing from the script loader callback.
  • The retry compares converted and input counts instead of ids, so deferred layers without an id are added too
  • Unit tests for convertInitialJson and for createDeck adding a deferred layer once its library loads

Split out of #10761, which needs this fix for its ZoomOpacityExtension example. Tracked in #10763.


Note

Medium Risk
Changes first-render and post-load JSON conversion in the jupyter-widget deck bootstrap path, but behavior is limited to decks with pending custom libraries and is covered by new tests.

Overview
Fixes the jupyter-widget case where a built-in layer references a custom-library extension (e.g. extensions: [{'@@type': 'ZoomOpacityExtension'}]) before that library loads. A failed full JSON conversion—or a layer built with extensions: [null]—used to abort createDeck and leave the map blank.

convertInitialJson still tries a full convert first; if that throws while custom libraries are pending, it converts the rest of the deck with empty layers/widgets, then converts each layer and widget in isolation so only the broken entries become null on the first paint. convertLayersAndWidgets is reused after libraries finish loading; failures are reported via onError instead of failing the whole update.

Deferred work is detected by comparing layer/widget counts to the input (replacing id-based missingProps), so layers without an id are still picked up on retry. Tests cover deferred conversion and an async createDeck path that adds the layer once the script loads.

Reviewed by Cursor Bugbot for commit 98c0092. Bugbot is set up for automated code reviews on this repo. Configure here.

@chrisgervang
chrisgervang marked this pull request as ready for review September 29, 2026 04:58
@chrisgervang
chrisgervang marked this pull request as draft September 29, 2026 04:58
@chrisgervang
chrisgervang marked this pull request as ready for review September 29, 2026 04:59
@chrisgervang
chrisgervang force-pushed the chr/jupyter-widget-custom-extensions branch from 44c1261 to 7af0914 Compare September 29, 2026 05:01
@chrisgervang
chrisgervang removed this pull request from stack #10765 September 29, 2026 05:02
@chrisgervang
chrisgervang changed the base branch from master to chr/pydeck-register-library-fix September 29, 2026 05:02
@coveralls

coveralls commented Sep 29, 2026 •

Copy link
Copy Markdown

Coverage Status

No base build to compare — chr/jupyter-widget-custom-extensions into master

@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Adds error handling for custom layer extensions in the deck initialization.

The PR appears safe to merge; no outstanding findings or new issues were identified.

Summary

The PR lets the Jupyter widget render convertible layers and widgets while custom libraries load, then retries deferred items after registration.

  • Handles layers with unloaded custom extensions, including layers without IDs.
  • Adds tests for initial deferral and restoration after library loading.
  • All three previous Greptile threads are resolved; the stale-update concern was explicitly accepted as out of scope and conceded.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Initial deck JSON] --> B{Full conversion succeeds?}
  B -->|Yes| C[Render converted props]
  B -->|No, libraries pending| D[Convert layers and widgets individually]
  D --> E[Render convertible items]
  D --> F[Defer failed items]
  F --> G[Custom libraries register]
  G --> H[Retry conversion and update Deck]
Loading

Reviews (5) · Last reviewed commit: "test(jupyter-widget): render the createD..."

Base automatically changed from chr/pydeck-register-library-fix to master October 1, 2026 22:11
…om libraries

A layer whose extensions come from a custom library converts with a
null extension until the library's script has loaded. Constructing
that layer throws, so createDeck failed and nothing rendered. Convert
the first render without layers and widgets when that happens, and add
them once the custom libraries load. Report conversion errors after
loading through onError.
Convert layers and widgets one at a time when the first conversion fails, so that
layers that do not depend on an unloaded custom library still render. After the
libraries load (or fail to), layers that still cannot be converted are reported
through onError instead of hiding the others. Retry based on counts rather than
ids, so layers without an id are also added once their library loads.
…est device

The headless project runs every spec in one page, so a deck with its own
WebGL context broke unrelated specs.
@chrisgervang
chrisgervang force-pushed the chr/jupyter-widget-custom-extensions branch from 7bffece to 98c0092 Compare October 1, 2026 22:11
@chrisgervang
chrisgervang merged commit 3d7eea1 into master Oct 1, 2026
8 checks passed
@chrisgervang
chrisgervang deleted the chr/jupyter-widget-custom-extensions branch October 1, 2026 22:31
@chrisgervang chrisgervang modified the milestones: v9.4, v9.4 patch releases Oct 4, 2026
@chrisgervang chrisgervang mentioned this pull request Oct 7, 2026
53 of 66 tasks
chrisgervang added a commit that referenced this pull request Oct 22, 2026
…om libraries (#10764)

* fix(jupyter-widget): render layers with extensions from unloaded custom libraries

A layer whose extensions come from a custom library converts with a
null extension until the library's script has loaded. Constructing
that layer throws, so createDeck failed and nothing rendered. Convert
the first render without layers and widgets when that happens, and add
them once the custom libraries load. Report conversion errors after
loading through onError.

* fix(jupyter-widget): defer only the layers that cannot be converted

Convert layers and widgets one at a time when the first conversion fails, so that
layers that do not depend on an unloaded custom library still render. After the
libraries load (or fail to), layers that still cannot be converted are reported
through onError instead of hiding the others. Retry based on counts rather than
ids, so layers without an id are also added once their library loads.

* test(jupyter-widget): render the createDeck test through the shared test device

The headless project runs every spec in one page, so a deck with its own
WebGL context broke unrelated specs.

(cherry picked from commit 3d7eea1)
@chrisgervang

Copy link
Copy Markdown
Collaborator Author

Released in deck.gl 9.4.1 as @deck.gl/[email protected].

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