Skip to content

Engine scene generation - #14685

Open
andrewvarga wants to merge 11 commits into
mainfrom
andrewvarga/adhoc/engine-scene-generation
Open

andrewvarga wants to merge 11 commits into
mainfrom
andrewvarga/adhoc/engine-scene-generation

Conversation

@andrewvarga

@andrewvarga andrewvarga commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Supersedes the recently added fromCache: #14645

I realized fromCache had issues: when returning from a sketch edit, it was true because exit_sketch calls run_with_caching, misses the cache, rebuilds the scene, and its outcome stays in Rust. KclManager's executeCode() then hits the cache and reports fromCache: true.

It's cleaner to have a counter which all clients can compare to their internal version and decide to update accordingly.
I realized TS already has a counter for the same purpose, so I connected the value coming from Rust to it, so now it's only incremented with actual changes, not on every execution - this surfaced a named view bug that I fixed in this PR and it can be used to avoid updates when the geometry remains the same.

@andrewvarga
andrewvarga requested review from a team as code owners October 19, 2026 15:46
@vercel

vercel Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
modeling-app Ready Ready Preview Oct 20, 2026 1:12pm UTC

Request Review

stopReapplyEffect = effect(() => {
const generation = kclManager.engineSceneGenerationSignal.value
if (generation === lastSeenGeneration) {
// reapplyActiveView does nothing while a sketch is open, so wait for it to close.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This bug exists on main too but it was not surfacing anything until using scene generation id from rust.

@codspeed

codspeed Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 157 untouched benchmarks
⏩ 131 skipped benchmarks1


Comparing andrewvarga/adhoc/engine-scene-generation (376ea68) with main (d3da241)2

Open in CodSpeed

Footnotes

  1. 131 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (252827e) during the generation of this report, so d3da241 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@andrewvarga

andrewvarga commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor Author

@jtran Sorry for tweaking but on second thought I prefer this over my previous fromCache version: #14645

Comment thread rust/kcl-lib/src/execution/mod.rs
}

pub(super) async fn bump_engine_scene_generation(&self) {
self.0.inner().write().await.engine_scene_generation += 1;

@jtran jtran Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What happens when it overflows? We should use an explicit policy of wrapping or saturating.

Does this ever get reset?

This branch was successfully deployed

1 active deployment
Preview — 376ea685 Deployed Oct 20, 2026 by vercel[bot]
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.

2 participants