Skip to content

Fix issue #215: stabilize heavy ipyleaflet rerenders#229

Draft
cpsievert wants to merge 4 commits intomainfrom
wip/issue-215-heavy-ipyleaflet-rerender
Draft

Fix issue #215: stabilize heavy ipyleaflet rerenders#229
cpsievert wants to merge 4 commits intomainfrom
wip/issue-215-heavy-ipyleaflet-rerender

Conversation

@cpsievert
Copy link
Copy Markdown
Collaborator

@cpsievert cpsievert commented Apr 10, 2026

Summary

  • fixes heavy ipyleaflet rerenders by opening child widget models before opening the parent widget model
  • upgrades the #215 Playwright regression to use a LayerGroup with 1,000 CircleMarkers so it matches the reported heavy-map failure mode
  • keeps the browser-side widget manager logic unchanged so the diff stays focused on the ordering bug itself

Problem

Issue #215 reports that rerendering an ipyleaflet map with many points can leave the map gray or unusable.

The failure mode here is that a parent widget view can start rendering before the browser knows about all child widget models referenced by that parent state. In ipyleaflet, that shows up as child-view creation failures and incomplete map rendering when a map has many layers.

Fix

This change keeps the existing delayed-open behavior for widget initialization, but narrows the ordering fix to one specific rule on the Python side:

  • before opening a widget comm, inspect that widget's serialized state
  • recursively open any referenced child widget models first
  • only then open the parent widget model

That preserves child-before-parent availability during initial render and rerender while keeping the browser-side code unchanged.

Evidence

I re-ran this from a clean origin/main worktree to make sure the final version still has a real red/green story.

Baseline with only the new heavy #215 repro applied:

  • tests/playwright/ipyleaflet_rerender_cleanup -vv fails on origin/main
  • the map container renders, but no path.leaflet-interactive elements ever appear within the 30s timeout

Then, applying only the _shinywidgets.py change from this branch on top of that clean baseline:

  • tests/playwright/ipyleaflet_rerender_cleanup -vv passes
  • tests/playwright/ipyleaflet_marker_click -vv passes
  • tests/playwright/plotly_rerender_cleanup -vv passes
  • tests/playwright/altair_rerender_cleanup -vv passes
  • tests/playwright/bokeh_rerender_cleanup -vv passes

That makes the current confidence story much stronger than the earlier exploratory versions of this branch: the heavy repro is red on baseline, and it turns green with this narrower Python-side fix alone.

Verification

Verified locally on this branch with:

  • yarn build
  • ./.venv/bin/python -m pytest -c tests/playwright/playwright-pytest.ini tests/playwright/ipyleaflet_marker_click -vv
  • ./.venv/bin/python -m pytest -c tests/playwright/playwright-pytest.ini tests/playwright/ipyleaflet_rerender_cleanup -vv
  • ./.venv/bin/python -m pytest -c tests/playwright/playwright-pytest.ini tests/playwright/plotly_rerender_cleanup -vv
  • ./.venv/bin/python -m pytest -c tests/playwright/playwright-pytest.ini tests/playwright/altair_rerender_cleanup -vv
  • ./.venv/bin/python -m pytest -c tests/playwright/playwright-pytest.ini tests/playwright/bokeh_rerender_cleanup -vv

@cpsievert cpsievert marked this pull request as ready for review April 10, 2026 20:32
@cpsievert cpsievert changed the title WIP: investigate issue #215 heavy ipyleaflet rerender Fix issue #215: stabilize heavy ipyleaflet rerenders Apr 10, 2026
@cpsievert cpsievert marked this pull request as draft April 10, 2026 20:41
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.

1 participant