Skip to content
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

[HOLD for payment 2023-11-29] [$500] Distance Request – The map is zoomed incorrectly after adding description #29469

Closed
3 of 6 tasks
kbecciv opened this issue Oct 12, 2023 · 38 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@kbecciv
Copy link

kbecciv commented Oct 12, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 1.3.83.1
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @paultsimura
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1697062856852229

Action Performed:

  1. Click FAB -> 'Request Money'
  2. Choose 'Distance'
  3. Add a route from point 1 to point 2:
  • 123 W Main St, Independence, KS 67301, USA
  • 321 Westminster Pl, Independence, KS 67301, USA
  1. Click on the "Next" button
  2. Select any WS
  3. Verify that the whole route is within the map boundaries
  4. Click "Description"
  5. Move back

Expected Result:

The route is within the map boundaries.

Actual Result:

The map is zoomed a bit too much, the route doesn't fit the map.

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
RPReplay_Final1697063034.MP4
MacOS: Chrome / Safari
bug-map-resize.mov
Recording.4972.mp4
MacOS: Desktop
bug-map-resize-desktop.mov

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~011040976b36d481db
  • Upwork Job ID: 1712503476731002880
  • Last Price Increase: 2023-10-12
  • Automatic offers:
    • paultsimura | Contributor | 27595967
    • paultsimura | Reporter | 27595970
@kbecciv kbecciv added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 12, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 12, 2023

Triggered auto assignment to @NicMendonca (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot melvin-bot bot changed the title Distance Request – The map is zoomed incorrectly after adding description [$500] Distance Request – The map is zoomed incorrectly after adding description Oct 12, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 12, 2023

Job added to Upwork: https://www.upwork.com/jobs/~011040976b36d481db

@melvin-bot
Copy link

melvin-bot bot commented Oct 12, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 12, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 12, 2023

Triggered auto assignment to Contributor-plus team member for initial proposal review - @Santhosh-Sellavel (External)

@kbecciv
Copy link
Author

kbecciv commented Oct 12, 2023

Proposal by: @paultsimura
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1697062856852229

Proposal

Please re-state the problem that we are trying to solve in this issue.

After opening "Description" editor on Distance Request confirmation, the map is incorrectly zoomed.

What is the root cause of that problem?

The root cause of this is that we use the ResizeObserver to resize the map. It's a good thing that was added in #27574 to fix the map being cut off.
However, we are facing a race condition when opening a map back from the "Distance" tab.
First, the boundaries are reset by this hook:

useEffect(() => {
if (!waypoints || waypoints.length === 0) {
return;
}
if (!mapRef) {
return;
}
if (waypoints.length === 1) {
mapRef.flyTo({
center: waypoints[0].coordinate,
zoom: 15,
});
return;
}
const map = mapRef.getMap();
const {northEast, southWest} = utils.getBounds(
waypoints.map((waypoint) => waypoint.coordinate),
directionCoordinates,
);
map.fitBounds([northEast, southWest], {padding: mapPadding});
}, [waypoints, mapRef, mapPadding, directionCoordinates]);

Then, mapRef.resize() is called here:

So the map is being resized after the boundaries have been reset.

What changes do you think we should make in order to solve the problem?

First, we should split this hook into a function resetBoundaries(), and call it in the hook.

        const resetBoundaries = useCallback(() => {
            ...current hook content here...
        }, [waypoints, mapRef, mapPadding, directionCoordinates]);
        useEffect(resetBoundaries, [resetBoundaries]);

useEffect(() => {
if (!waypoints || waypoints.length === 0) {
return;
}
if (!mapRef) {
return;
}
if (waypoints.length === 1) {
mapRef.flyTo({
center: waypoints[0].coordinate,
zoom: 15,
});
return;
}
const map = mapRef.getMap();
const {northEast, southWest} = utils.getBounds(
waypoints.map((waypoint) => waypoint.coordinate),
directionCoordinates,
);
map.fitBounds([northEast, southWest], {padding: mapPadding});
}, [waypoints, mapRef, mapPadding, directionCoordinates]);

And then, we should call resetBoundaries() after the resize:

            const resizeObserver = new ResizeObserver(() => {
                mapRef.resize();
+               resetBoundaries();
            });

https://github.com/Expensify/App/blob/05ab7ed1920b2e55f517cea7dc73c16f13d8fac7/src/components/MapView/MapView.web.tsx#L58-L60C16

Result:

https://user-images.githubusercontent.com/12595293/274435387-c286a5c8-9789-4fd9-98c7-025705352aef.mov
P.s. Since the resize happens only on a tab change, this will be a safe addition, which will also solve the issue of not resetting the zoom of the map when navigating back to the initial waypoints selection page. This one:
https://user-images.githubusercontent.com/12595293/274653852-d71fe309-cdd9-4508-9d28-60a13accb565.mov

What alternative solutions did you explore? (Optional)

@paultsimura
Copy link
Contributor

Proposal

Please re-state the problem that we are trying to solve in this issue.

After opening "Description" editor on Distance Request confirmation, the map is incorrectly zoomed.

What is the root cause of that problem?

The root cause of this is that we use the ResizeObserver to resize the map. It's a good thing that was added in #27574 to fix the map being cut off.

However, we are facing a race condition when opening a map back from the "Distance" tab.

First, the boundaries are reset by this hook:

useEffect(() => {
if (!waypoints || waypoints.length === 0) {
return;
}
if (!mapRef) {
return;
}
if (waypoints.length === 1) {
mapRef.flyTo({
center: waypoints[0].coordinate,
zoom: 15,
});
return;
}
const map = mapRef.getMap();
const {northEast, southWest} = utils.getBounds(
waypoints.map((waypoint) => waypoint.coordinate),
directionCoordinates,
);
map.fitBounds([northEast, southWest], {padding: mapPadding});
}, [waypoints, mapRef, mapPadding, directionCoordinates]);

Then, mapRef.resize() is called here:

useEffect(() => {
if (!mapRef) {
return;
}
const resizeObserver = new ResizeObserver(() => {
mapRef.resize();
});
resizeObserver.observe(mapRef.getContainer());
return () => {
resizeObserver?.disconnect();
};
}, [mapRef]);

So the map is being resized after the boundaries have been reset.

What changes do you think we should make in order to solve the problem?

First, we should split this hook into a function resetBoundaries(), and call it in the hook.

        const resetBoundaries = useCallback(() => {
            ...current hook content here...
        }, [waypoints, mapRef, mapPadding, directionCoordinates]);

        useEffect(resetBoundaries, [resetBoundaries]);

useEffect(() => {
if (!waypoints || waypoints.length === 0) {
return;
}
if (!mapRef) {
return;
}
if (waypoints.length === 1) {
mapRef.flyTo({
center: waypoints[0].coordinate,
zoom: 15,
});
return;
}
const map = mapRef.getMap();
const {northEast, southWest} = utils.getBounds(
waypoints.map((waypoint) => waypoint.coordinate),
directionCoordinates,
);
map.fitBounds([northEast, southWest], {padding: mapPadding});
}, [waypoints, mapRef, mapPadding, directionCoordinates]);

And then, we should call resetBoundaries() after the resize:

            const resizeObserver = new ResizeObserver(() => {
                mapRef.resize();
+               resetBoundaries();
            });

const resizeObserver = new ResizeObserver(() => {
mapRef.resize();
});

Result:

web.mov

P.s. Since the resize happens only on a tab change, this will be a safe addition, which will also solve the issue of not resetting the zoom of the map when navigating back to the initial waypoints selection page. This one:

bug-map-resize-comeback.mov

What alternative solutions did you explore? (Optional)

P.p.s. thank you @kbecciv, I've reposted my proposal just to keep better formatting, as Slack messes it up a little bit.

@NicMendonca
Copy link
Contributor

@Santhosh-Sellavel proposals for ya!

@melvin-bot melvin-bot bot added the Overdue label Oct 16, 2023
@Santhosh-Sellavel
Copy link
Collaborator

@kbecciv @NicMendonca Can you check again, this seems to be working fine already!

@melvin-bot melvin-bot bot removed the Overdue label Oct 16, 2023
@paultsimura
Copy link
Contributor

paultsimura commented Oct 16, 2023

@kbecciv @NicMendonca Can you check again, this seems to be working fine already!

@Santhosh-Sellavel did you test on Web/mWeb? Native platforms use different SDK and it's not reproducible there.

Also, this was reproduced just now (both staging and prod):
https://github.com/Expensify/App/assets/12595293/96e1c3c8-612f-4b47-a7fa-7d1240361d98

@Santhosh-Sellavel
Copy link
Collaborator

Santhosh-Sellavel commented Oct 16, 2023

mWeb/web

@paultsimura
Copy link
Contributor

Please also make sure to use the points that are relatively close (the ones from the issue description are a perfect match). The zoom lag on large distances is not that noticeable.

@Santhosh-Sellavel

@Santhosh-Sellavel
Copy link
Collaborator

Alright got it, thanks @paultsimura!

@Santhosh-Sellavel
Copy link
Collaborator

@paultsimura #29469 (comment) looks good to me!

C+ Reviewed
🎀 👀 🎀

@melvin-bot
Copy link

melvin-bot bot commented Oct 16, 2023

Triggered auto assignment to @deetergp, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@situchan
Copy link
Contributor

I suggest to put this on hold for #26724 which was on hold for #28911

@melvin-bot melvin-bot bot added the Overdue label Oct 19, 2023
@deetergp
Copy link
Contributor

I agree with @situchan, that this should go into the hold chain. #28911 was merged earlier this morning and should go out to Staging once the current round of QA on staging is done.

@melvin-bot melvin-bot bot removed the Overdue label Oct 19, 2023
@NicMendonca NicMendonca changed the title [$500] Distance Request – The map is zoomed incorrectly after adding description Hold for #26724] [$500] Distance Request – The map is zoomed incorrectly after adding description Oct 20, 2023
@NicMendonca NicMendonca removed the Daily KSv2 label Oct 20, 2023
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Nov 22, 2023
@melvin-bot melvin-bot bot changed the title [$500] Distance Request – The map is zoomed incorrectly after adding description [HOLD for payment 2023-11-29] [$500] Distance Request – The map is zoomed incorrectly after adding description Nov 22, 2023
Copy link

melvin-bot bot commented Nov 22, 2023

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Nov 22, 2023
Copy link

melvin-bot bot commented Nov 22, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.1-13 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-11-29. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Nov 22, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@Santhosh-Sellavel] The PR that introduced the bug has been identified. Link to the PR:
  • [@Santhosh-Sellavel] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@Santhosh-Sellavel] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@Santhosh-Sellavel] Determine if we should create a regression test for this bug.
  • [@Santhosh-Sellavel] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@NicMendonca] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Nov 28, 2023
@paultsimura
Copy link
Contributor

@deetergp a friendly bump on the payout here, please☝️

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Dec 1, 2023
@NicMendonca
Copy link
Contributor

BZ Payment summary:
Reporter: @paultsimura - $50
Contributor: @paultsimura - $500
C+ @Santhosh-Sellavel - $500

@Santhosh-Sellavel don't forget to request payment via Expensify!

@paultsimura you've been paid via Upwork!

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Dec 4, 2023
@NicMendonca
Copy link
Contributor

@Santhosh-Sellavel bump on this! #29469 (comment)

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Dec 7, 2023
Copy link

melvin-bot bot commented Dec 11, 2023

@deetergp, @paultsimura, @NicMendonca, @Santhosh-Sellavel Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@NicMendonca
Copy link
Contributor

@Santhosh-Sellavel
Copy link
Collaborator

Santhosh-Sellavel commented Dec 11, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

@Santhosh-Sellavel
Copy link
Collaborator

Santhosh-Sellavel commented Dec 11, 2023

Bug: Distance Request – The map is zoomed incorrectly after adding a description

Regression Steps

  1. Click FAB -> 'Request Money'
  2. Choose 'Distance'
  3. Add a route from point 1 to point 2: Any two locations
  4. Click on the "Next" button
  5. Select any WS
  6. Verify that the whole route is within the map boundaries
  7. Edit Description, go back
  8. Verify that the whole route is within the map boundaries

@NicMendonca
Copy link
Contributor

Thanks @Santhosh-Sellavel!

BZ Payment summary:
Reporter: @paultsimura - $50
Contributor: @paultsimura - $500
C+ @Santhosh-Sellavel - $500

@Santhosh-Sellavel don't forget to request payment via Expensify!

@paultsimura you've been paid via Upwork!

@Santhosh-Sellavel
Copy link
Collaborator

Request On ND

@JmillsExpensify
Copy link

$500 payment approved for @Santhosh-Sellavel based on comment above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

9 participants