-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Fix maintainVisibleContentPosition in Safari #47193
Fix maintainVisibleContentPosition in Safari #47193
Conversation
ac80158
to
cd5b1fb
Compare
After doing more testing it seems like Safari on iOS is still problematic, this only fixes desktop. Investigating. |
The issue on mobile safari seems to be very hard to fix, I have tried many things but I haven't been able to get safari to change the scroll position while a momentum scroll is happening. The only workaround I found is to disable scrolling then update the scroll position then re-enable scrolling, but this will cause the momentum scroll to stop which makes scrolling not smooth, but in my opinion a pretty good improvement over a giant jump like it does currently. I will try to investigate some other websites that have bidirectional scroll to see if they handle mobile safari better than this. |
I tested slack on iOS safari and they seem to use a similar workaround, the scroll down after linking to a message is a bit jumpy and momentum scroll keeps stopping. RPReplay_Final1723913579.mov |
@ahmedGaber93 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
@ishpaul777 This is ready if you wanna have a look! |
For sure, i'll start tomorrow. @ahmedGaber93 you can ignore this one |
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-08-31.at.2.10.11.AM.movAndroid: mWeb ChromeScreen.Recording.2024-08-31.at.2.17.58.AM.moviOS: NativeScreen.Recording.2024-08-31.at.1.46.44.AM.moviOS: mWeb SafariScreen.Recording.2024-08-31.at.1.42.40.AM.movMacOS: Chrome / SafariScreen.Recording.2024-08-31.at.1.32.22.AM.movScreen.Recording.2024-08-31.at.1.13.58.AM-1.movMacOS: DesktopScreen.Recording.2024-08-31.at.2.14.46.AM-1.mov |
FI, i plan to review this today, was OOO past few days |
Sadly i am still seeing some content jumping in desktop safari and few times after linking to first message new message do not load when scrolling down Screen.Recording.2024-08-20.at.7.27.46.PM-1.mov |
@ishpaul777 Can you try again to see if the scroll still gets stuck sometimes, I just merged main which has the fixes from #46315. |
pulling latest commit cause some weird janky scrolling in opposite direction and also some white screen and some content jumping is still present Screen.Recording.2024-08-20.at.9.21.02.PM.mov |
I cannot currently reproduce the blanking issue, but I did find one more problem that I would like to address before merging this. It seems like adjusting the scroll position is not reliable on the web across browsers. We might need to use a different virtualization strategy if we want to have perfectly smooth bidirectional pagination. If I link to the first message, then scroll back all the way to the bottom of the chat back to where the links are, then link to the first message again the scroll position is wrong. |
Added one more fix for the case
The problem was that 2 important values ended up being updated at different time and the list would render with old data which would mess up the scroll positioning.
|
Oh god! This PR got off my radar since i am not assigned to this, will priortize for today. |
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.
Comment so this shows on my K2 extension
Finishing this few minutes, Sorry for delay |
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.
Looks good! just one comment
@@ -4483,7 +4483,7 @@ const CONST = { | |||
REPORT_FIELD_TITLE_FIELD_ID: 'text_title', | |||
|
|||
MOBILE_PAGINATION_SIZE: 15, | |||
WEB_PAGINATION_SIZE: 50, | |||
WEB_PAGINATION_SIZE: 30, |
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.
Could you explain the reason please
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.
This seemed to help reduce jumping, when loading more messages I noticed that often the first visible view that we use in the maintainVisibleContentPosition implementation would be removed. When reducing this it stopped happening.
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.
I do not see any downsides here, so sounds good 👍 Thanks for clarifying!
We did not find an internal engineer to review this PR, trying to assign a random engineer to #47518 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
@janicduplessis would you mind taking one more look here as well? |
@stitesExpensify Sorry I am not sure what you mean here |
@janicduplessis so sorry, I didn't have my head on straight this morning. I thought that you were a reviewer not the author 🤦 |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/stitesExpensify in version: 9.0.29-0 🚀
|
🚀 Deployed to production by https://github.com/roryabraham in version: 9.0.29-12 🚀
|
Details
The maintainVisibleContentPosition implementation currently doesn't work properly. This fixes it.
I noticed some cases that caused some jumping:
Sometimes the first visible view will be removed from the DOM and it would cause an incorrect adjustment. To fix this we can detect in the mutation observer that the node removed is the first visible view, and calculate a new one when it happens. Also reduce the pagination size to reduce cases where the first visible view could be removed.
We do the adjustment in a
requestAnimationFrame
, but this gives time for a scroll event to happen before we get to adjust the scroll position and we lose the proper positioning. It seemed to be needed in chrome, but I found a better way, we can instead use the last scroll position from the previous scroll event instead and it works fine without the need ofrequestAnimationFrame
on both chrome and safari.Add some hacks to mobile safari since adjusting scroll position during momentum scroll does not work.
Before:
Screen.Recording.2024-08-15.at.21.52.09.mov
After:
Screen.Recording.2024-08-15.at.21.49.13.mov
Fixed Issues
$ #47518
PROPOSAL:
Tests
Offline tests
QA Steps
Verify that no errors appear in the JS console
Check that scrolling down is smooth after comment linking using the following steps
In a chat with many messages copy the link to a message and send it
Click on the message link from the first step
Scroll down
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
N/A
Android: mWeb Chrome
Screen.Recording.2024-08-15.at.22.15.06.mov
iOS: Native
N/A
iOS: mWeb Safari
Screen.Recording.2024-08-17.at.15.52.22.mov
MacOS: Chrome / Safari
Safari
Screen.Recording.2024-08-15.at.21.46.15.mov
Chrome
Screen.Recording.2024-08-15.at.21.54.31.mov
MacOS: Desktop
Screen.Recording.2024-08-17.at.15.43.57.mov