Skip to content

Lineage: initial view never fit-views the graph — only centers the root node at a fixed zoom, leaving large graphs mostly off-screen #34603

Closed

Description

@wank125

Description

When opening the lineage view for an entity whose graph is larger than the viewport (e.g. a hub table with 19+ downstream nodes laid out in a tall column), the initial view does not fit the graph into the viewport. Instead, only the root node is centered at a fixed zoom, so most nodes and edges render outside the visible area. Users perceive the page as broken/stuck ("all edges converge to one point and disappear"), especially since the layout engine keeps working on the off-screen portion.

Related but distinct from #29815 (that one was about the Fit to Screen button malfunctioning and was fixed by #30163). Here the initial draw never fit-views at all, on 2.0.3-release.

Environment

  • Version: OpenMetadata 2.0.3-release (commit b76076b), UI served from openmetadata-ui-2.0.3.jar
  • Deployment: Docker quickstart (docker-compose)
  • Browser: Chrome (also reproduced with an embedded WebKit/Chromium view)
  • OS: macOS

Steps to reproduce

  1. Import metadata + lineage so that one entity has many downstream/upstream nodes — e.g. a table s4_bsis_2024 with 1 upstream and 19 downstream tables; after ELK layout the graph spans roughly 1900×3300 px.
  2. Open http://<host>:8585/lineage/table/<fqn> (or the Lineage tab on the entity page).
  3. Observe the initial viewport once loading finishes.

Current behavior

  • The viewport is set by centerNodePosition(rootNode, instance, zoomValue) — i.e. the root node centered at a fixed zoom (~0.65 default).
  • With a 3300 px tall graph in a ~900 px tall viewport, everything except the band around the root node is off-screen.
  • fitViewOptions={{ padding: 48 }} is configured on <ReactFlow> in components/Lineage/Lineage.component.tsx, but fitView is never enabled/invoked on the initial draw, so the option is inert.

Expected behavior

After the initial ELK layout completes, the whole graph should be fitted into the viewport (as the "Fit to screen" control does when invoked manually on a simple graph).

Root cause

In openmetadata-ui/src/main/resources/ui/src/context/LineageProvider/LineageProvider.tsx, redrawLineage() handles the initial draw when called with recenter === true (all initial-load paths do: fetchLineageData, fetchPlatformLineage, and onInitReactFlow). That branch only calls centerNodePosition(...), which uses instance.setCenter(..., { zoom }) — a center-at-fixed-zoom operation that never scales to the graph bounds.

Suggested fix

After the laid-out nodes are committed (setNodes(visibleNodes)), call instance.fitView(...) when recenter === true (keep centerNodePosition for the string/node-focus case):

setNodes(visibleNodes);
setEdges(visibleEdges);
setColumnsHavingLineage(columnsLineageSet);

if (recenter === true) {
  // Fit the laid-out graph into the viewport once the new node
  // positions are committed to the flow store.
  await new Promise((resolve) =>
    requestAnimationFrame(() => requestAnimationFrame(resolve))
  );
  activeReactFlowInstance.fitView({
    duration: 400,
    maxZoom: Math.max(zoomValue ?? 1, 1),
    padding: 0.1,
  });
}

Verified locally on 2.0.3-release: after rebuilding the UI with this change, the same 24-node/3300px graph loads at scale ≈ 0.167 with all nodes inside the viewport, stable across reloads; the node-focus recentering path is unaffected.

Additional context

  • The double requestAnimationFrame wait is needed so the freshly positioned nodes are committed to the react-flow store before fitView computes bounds.
  • A stale zoomValue persisted in localStorage can mask the symptom in testing — worth clearing when reproducing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

UI

Type

No type

Projects

  • Status
    Done ✅

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions