Bound the submit-time geolocation lookup with a timeout - #100045
Draft
adhorodyski wants to merge 2 commits into
Draft
Bound the submit-time geolocation lookup with a timeout#100045adhorodyski wants to merge 2 commits into
adhorodyski wants to merge 2 commits into
Conversation
Contributor
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation of Change
src/libs/getCurrentPosition/index.tsis the only implementation of the app'sgetCurrentPosition. It now readsgetLastKnownPositionAsyncfirst, then falls back to a live request bounded byCONST.GPS.TIMEOUT(15s). A patch adds thetimeoutfield expo-location lacks, forwarding it to Android'ssetDurationMillis(). NewCONST.GPS.MAX_AGEis 60s, becauseAddressSearchandMapViewshare the helper.Why:
ManualGeolocationWaitspans peaked at 30,385ms over 7 days, across 20,930 samples, 392 of them above 5s.LocationHelpers.prepareCurrentLocationRequestnever callssetDurationMillis(), leaving the Play Services default in force.Fixed Issues
$
PROPOSAL:
Tests
npx jest tests/unit/getCurrentPositionTest.ts. Five tests pass: the live request receivestimeout: CONST.GPS.TIMEOUT; a platform rejection surfaces as a failure and never as a position; a cached fix newer thanCONST.GPS.MAX_AGEis served without a live request; a missing cached fix falls back to a live request; a denied permission short-circuits before the cache or a live request is touched.npx jest tests/ui/SubmitDetailsPageTest.tsx tests/ui/components/IOURequestStepConfirmationPageTest.tsx. All 31 tests pass.npx jest tests/actions/IOU/MoneyRequestTest.ts. All 75 tests pass.npm run typecheck. No errors insrc/libs/getCurrentPosition/index.ts,src/CONST/index.ts,jest/setup.ts, ortests/unit/getCurrentPositionTest.ts. To confirm the patchedLocationOptionstype is actually in effect, replacetimeoutwith a bogus key and check thatTS2353fires on that line.node_modules/expo-location, runnpm install, and confirmsetDurationMillisis present innode_modules/expo-location/android/src/main/java/expo/modules/location/LocationHelpers.kt.Offline tests
QA Steps
CLLocationManager.AddressSearchand tap "use my current location". Verify the returned address is still correct and not visibly stale.PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari