New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure that viewport dimensions are updated when expanding/collapsing iframe #9897
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did I read correctly: the CachedValueObservable
and CANCEL_FULL_OVERLAY_FRAME_REMEASURE
were introduced for an optimization, which is to not remeasure inside the inabox runtime for every scroll or resize when it's in overlay mode.
If so, would the following work:
- we store the latest position change locally, and skip
remeasureAll
if it's in overlay mode - when
CANCEL_FULL_OVERLAY_FRAME_RESPONSE
is returned, we use the latest viewport position to do aremeasureAll
.
Just doing that would lead to an incorrect state if the viewport changes while the overlay is open. |
Any viewport change of the host page should be sent to the iframe, even when overlay is open. Why there will be incorrect state? |
Because the collapsed box rect hasn't been recalculated after the viewport change. We know what the box rect looks like when expanded, but not what it will look like when being collapsed again. |
That part makes sense. But I still don't understand why host has to respond 2 separate responses, and upon receiving those responses, client remeasure twice. Is that an optimization because most of the time the box won't change (since we freeze the scroll), so the 2nd response is considered as a sanity check adjustment ? |
Yep. If we always remeasure we're always going to skip a frame because recalculation requires a vsync pass. It's not just optimization for optimization sake, it would be bad UX otherwise since elements could jump or the change would be laggy. |
8ebba43
to
1a8c7a1
Compare
@lannka PTAL Moved the collapsed rect cache logic to host per off-thread discussion. Refactored it so it would be simpler. Even the tests are simpler using this approach! |
@lannka ping |
Awesome! Thanks for the change. |
Uses known information about the frame collapsed state. Invalidates cached rect if the viewport changes.