Repository navigation
perf: compiled style plans and diffed state application, B18 as 1.6.4, the final fix wave (1.8 stream S) - #91
Merged
Merged
Conversation
…am S), B18 as 1.6.4, the final fix wave Ports 1.8's net change across three merges, applied as one 3-way patch so main's #73 border-shader swap is merged once, against the final code: - 0932889 Merge stream S: compiled style plans, diffed state application - 8886583 Merge the final fix wave: no per-call closures on hot paths - de1d782 Merge: remove the B18 fix (Checkpoint 2); border and shadow writes as 1.6.4 Stream S: a $state block, border or shadow object is compiled once and cached by identity (src/core/stylePlan.ts). A state change writes only the keys whose resolved value changed; the border keys are rewritten together in tracked order when one of them changes, as 1.6 did. Assigning an unchanged `states` list does nothing. Setting a gradient again updates the shader it made. B18 stays a known bug (1.6.4 behaviour). Final fix wave, the parts main did not have: the layout phase inline in the post-mutation pass; insertChild, removeChild, animate(), render(), destroy() and _listenTextLoaded without per-call closures or contexts; TextMeasure declares its fields (measureFontWaiting is a static method); flex scratch arrays grown inline; preFlex sizes in the constructor; one shared animation-settings object; onAnimation.stopped without a closure per write; render() reads onEvent with for-in (Chrome 47). Left out, as main already has them: the fix wave's focusManager.ts (8161b66, 7fcd44c; #71) and states.ts (e9a3713, f7b5481; #71) changes and Virtual.tsx (037c0f5; #72). main's tests/states.test.tsx is kept. Merged with main: - #73: the shader accessor and the effects setter keep writing the sub-props into _shaderProps and call _syncShaderType, so a shader convertToShader made still swaps to or from roundedWithBorder when a border width moves to or from 0 (before an animation reads its start values; after it stops for one shrinking to 0). main's convertToShader is kept. - #71's parseAndAssignShaderProps name cache (borderSideMap, shaderPropNames) is replaced by stylePlan's shaderParse. - tests/webgl/shader-props.test.tsx N5 registers roundedWithBorderWithShadow and expects a border written after a shadow to swap to it, per #73; a shadow after a border keeps roundedWithBorder. (cherry picked from commits 0932889, 8886583, de1d782 on 1.8, net) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…gn 3.3.1) main's test pinned the 1.6 result, where an object changed in place and assigned again wrote its new values. Stream S parses a border or shadow object once and caches it by identity: assign a new object instead. The test now checks both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports 1.8's Stream S (compiled style plans, diffed state application), the B18 removal you decided at Checkpoint 2, and the rest of the final fix wave. This follows #89 and #90.
The three 1.8 merges (
0932889,8886583,de1d782) are applied as one net 3-way patch rather than commit by commit. Picking S on its own first would have meant merging main's #73 border-shader swap into B18 code that the removal then deletes. This way #73 is merged once, against the final code.What's in it
Stream S (new
src/core/stylePlan.ts)$stateblock, and aborderorshadowobject, is compiled once and cached by object identity. A getter in a$stateblock is still read on every apply.border,borderTop,borderRight,borderBottom,borderLeft): when a change writes one of them, they are all written again in order, as 1.6 did, so the sides and the whole border combine as before.stateslist does nothing. That covers an array or string with the same states in the same order, or an object that adds and removes nothing.linearGradientorradialGradientagain updates the shader it made instead of creating a new one.it.skip('BUG: B18 …').Final fix wave: hot paths without per-call closures under terser's default
reduce_funcsinsertChild,removeChild,animate(),render(),destroy()and_listenTextLoadedallocate no closure or context per call.TextMeasuredeclares its fields;measureFontWaitingbecomes a static method of it.preFlexwidthandpreFlexheightare set in the constructor.onAnimation.stoppedis called through the timer's arguments instead of a closure per write.render()readsonEventwithfor…in, for Chrome 47.Behaviour changes for apps
$focusscalekeeps animating when$activeis added.node.border = { width: 6, color: GREEN }made while$focussets a blue border stays green when$hover: { alpha: 0.5 }is added; 1.6 showed blue again. The border-key exception above still rewrites borders together.theme, elsestyle) is===the value the state wrote, the undo skips the key. Otherwise it restorestheme, thenstyle, thenundefined, as before.$state,borderorshadowobject in place after its first use is not seen. Assign a new object or use a getter. Main'stests/shaderProps.test.tspinned the old result and now checks both cases.stateslist no longer re-applies the states.forwardStates, a child that changed its own states keeps them until the parent's list actually changes.node.states = node.statesno longer empties the list.Merged with main
effectssetter still mirror each write into_shaderPropsand call_syncShaderType. A shaderconvertToShadermade therefore still swaps to or fromroundedWithBorderwhen a border width moves to or from 0, before an animation reads its start values, and after the animation stops for a border shrinking to 0.convertToShaderis kept.borderSideMap,shaderPropNames) is replaced byshaderParseinstylePlan.ts, which caches per object and maps border sides the same way.tests/webgl/shader-props.test.tsx): it pinned 1.6.4's rule that the first write picks the shader type. With fix(shaders): use the rounded shader while a border's width is 0 #73, a border written after a shadow swaps toroundedWithBorderWithShadowso the border draws. The test now registers that type and expects the swap. A shadow written after a border still keepsroundedWithBorder.focusManager.tsitems (8161b66,7fcd44c) andstates.tsitems (e9a3713,f7b5481), both covered by perf: remove per-press allocations (no functional change) #71, andVirtual.tsx(037c0f5, covered by Backport 1.8 bug fixes to 1.7 (B1, B3, B4, B13–B17, B21, renderer 2.0 compat) #72). Main'stests/states.test.tsxis kept.Measured gains (from 1.8's
docs/perf/log.mdand Checkpoint 2 report)_stateChangedinclusive time 49.0 → 37.6 µs per press on thumbnail-focus, and 98.4 → 73.8 µs on navdrawer-toggle.reduce_funcs. The bundle now has none on a per-press path.Found while merging, not changed here
On
maintoday, #73 swaps aroundedWithShadownode toroundedWithBorderWithShadowwhen a border is added. If an app registered only some types, as the demo app does,createShaderreturns null for that type and the node loses its shader._syncShaderTypecould keep the current shader when the new type isn't registered. That would be a separate fix to #73.Testing
npm run tsc,npm run lintandnpm run buildpass.npm test: 767 passed, 2 skipped (one is the deliberateBUG: B18skip). Same result with 4 workers, with 1 worker, and with shuffled file orders (seeds 3, 4, 5).npm run test:webgl: 67 of 67 pass, including 1.8's newshader-propssuite and main'sborder-shadersuite.🤖 Generated with Claude Code