-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
refactor(datetime): use scroll listener to detect month changes #25586
Conversation
This reverts commit eaf0b87.
Open question: Should we remove the tests that were added to account for IntersectionObserver-related quirks? For example, the sub-pixel-width and zoom tests |
Yeah I think removing the sub-pixel and zoom tests makes sense now that we don't have a dependency on an intersection observer. |
^ Agreed. |
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.
Awesome work on this, should save us a bunch of trouble 😁
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.
Death to the IO 💀
This problem is most serious in earlier versions of Android and Huawei Hongmeng system. Thank you for solving this problem. |
Pull request checklist
Please check if your PR fulfills the following requirements:
ionic-docs
repo, in a separate PR. See the contributing guide for details.npm run build
) was run locally and any changes were pushednpm run lint
) has passed locally and any fixes were made for failuresPull request type
Please check the type of change your PR introduces:
What is the current behavior?
Issue URL: resolves #24980, resolves #25257
The datetime component in v6 was originally built using IntersectionObserver to detect when the month was swiped. This was done as it was easy to configure and had minimal impact on performance. Unfortunately, the implementation of IntersectionObserver across browsers is inconsistent, buggy, and overall unreliable for our use case.
Related issues:
#25007
#24482
#24472
#24405
#23992
#23985
#25257
#24980
We have made several patches to avoid these issues. However, the team has decided to look into using a
scroll
listener instead to improve the reliability of the component.What is the new behavior?
This PR makes the following changes:
overlayIsPresenting
hackonIonChange
hacks for the picker wheels.Note: The following hacks for Safari 14 are still relevant as the
scroll
event is also impacted:ionic-framework/core/src/components/datetime/datetime.tsx
Line 1277 in 420f9bb
Does this introduce a breaking change?
Other information
Dev build:
6.1.14-dev.11657300607.18e0f2d1
Performance
The performance difference is pretty minimal. The following stats were taken from an iPhone 7 running iOS 15.4.1.
(I also tested iOS 13 + iOS 14 and saw no behavior quirks)
Overall the CPU usage remained about the same. The
main
branch does show a slightly higher average CPU usage, but the difference between the two averages is only a few percentage points.The screenshot with the scroll listener does show significantly more timers which is to be expected. Additionally, there is more purple (JavaScript & Events). We are using
setTimeout
to detect the end of the scroll gesture and cancelling it every time a new scroll event is dispatched.main
branchdatetime-scroll-listener
branchI also tested this on a Samsung Galaxy S3 (https://www.gsmarena.com/samsung_galaxy_s_iii_cdma-4799.php) running Android 4.4 with Chrome 81. The phone was too slow to take a timeline in Chrome dev tools, but the swiping experience between
main
and this branch was very similar.