Hi,I changed the line 1606 from:
if(uiMode) LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)tr.parent);
To:
if(uiMode) LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)tr.root);
But it look like the problem still exists. (Did I miss something?)
And about code if(uiMode) LayoutRebuilder.MarkLayoutForRebuild(tr);
,the update after one frame. (Maybe this,I used the MarkLayoutForRebuild of line 1604)

I think that is because the Rebuild() function called in the Update() function when rect changed.
But it only woks in UNITY_EDITOR mode, not works in build.
With the if(uiMode) LayoutRebuilder.MarkLayoutForRebuild(tr); added,
and add the code below somewhere
void OnRectTransformDimensionsChange() { if (uiMode) Rebuild(); }
it seems to work.