Update color handling and enhance session management in the Reconciler

- Added 'Name' to the list of excluded property names in the rbx_dom_lua module to prevent unnecessary comparisons.
- Updated color handling in the diff stress tests to use Color3.fromRGB for better precision and clarity in color representation.
- Improved the hydrate function to initialize a new session if none is provided, enhancing session management during instance hydration.
- Refined the trueEquals function to handle NaN comparisons correctly, ensuring accurate equality checks for numeric values.

These changes improve the accuracy of property comparisons and enhance the overall functionality of the Reconciler module.
This commit is contained in:
Joe 2026-02-18 06:59:03 -06:00
parent ddd47b9afa
commit 30e032b27e
5 changed files with 15 additions and 11 deletions

View file

@ -44,6 +44,7 @@ end
local EXCLUDED_PROP_NAMES: { [string]: boolean } = {
Tags = true,
Attributes = true,
Name = true,
}
-- Encoded value type keys that cannot be compared during matching.

View file

@ -431,13 +431,13 @@ return function()
local part = Instance.new("Part")
part.Name = "TestPart"
part.Color = Color3.new(1, 0.5, 0.25)
part.Color = Color3.fromRGB(255, 128, 64)
part.Parent = container
local rootId = generateId()
instanceMap:insert(rootId, part)
-- Same color values (exact match)
-- Same color values (exact 8-bit match avoids quantization mismatch)
local virtualInstances = {
[rootId] = {
Id = rootId,
@ -446,7 +446,7 @@ return function()
Parent = nil,
Properties = {
Color = {
Color3 = { 1, 0.5, 0.25 },
Color3 = { 255 / 255, 128 / 255, 64 / 255 },
},
},
Children = {},

View file

@ -14,6 +14,10 @@ local invariant = require(script.Parent.Parent.invariant)
local Matching = require(script.Parent.matching)
local function hydrate(instanceMap, virtualInstances, rootId, rootInstance, session)
if not session then
session = Matching.newSession()
end
local virtualInstance = virtualInstances[rootId]
if virtualInstance == nil then

View file

@ -90,6 +90,9 @@ local function trueEquals(a: any, b: any): boolean
end
if t == "number" then
if a ~= a then
return b ~= b
end
return fuzzyEq(a, b)
end
if t == "Color3" then
@ -105,10 +108,6 @@ local function trueEquals(a: any, b: any): boolean
return cframeEq(a, b)
end
if a ~= a and b ~= b then
return true
end
return false
end

View file

@ -187,12 +187,12 @@ return function()
expect(trueEquals(Color3.fromRGB(128, 128, 128), Color3.fromRGB(129, 128, 128))).to.equal(false)
end)
it("near-boundary same floor", function()
expect(trueEquals(Color3.new(128 / 255, 0, 0), Color3.new(128.4 / 255, 0, 0))).to.equal(true)
it("near-boundary within epsilon", function()
expect(trueEquals(Color3.new(0.5, 0, 0), Color3.new(0.50005, 0, 0))).to.equal(true)
end)
it("near-boundary different floor", function()
expect(trueEquals(Color3.new(128 / 255, 0, 0), Color3.new(129 / 255, 0, 0))).to.equal(false)
it("near-boundary beyond epsilon", function()
expect(trueEquals(Color3.new(0.5, 0, 0), Color3.new(0.502, 0, 0))).to.equal(false)
end)
end)