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

front: call pathfinding only once #9733

Closed
wants to merge 1 commit into from

Conversation

anisometropie
Copy link
Contributor

@anisometropie anisometropie commented Nov 15, 2024

closes #6719

Ignore the vias changes made automatically from the pathfinding result which resulted in a new pathfinding request.

@codecov-commenter
Copy link

codecov-commenter commented Nov 15, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 31.81818% with 30 lines in your changes missing coverage. Please review.

Project coverage is 37.81%. Comparing base (1cec9ef) to head (9459907).
Report is 237 commits behind head on dev.

Files with missing lines Patch % Lines
...nt/src/modules/pathfinding/hooks/usePathfinding.ts 3.44% 28 Missing ⚠️
...ront/src/reducers/osrdconf/osrdConfCommon/index.ts 92.85% 1 Missing ⚠️
.../src/reducers/osrdconf/osrdConfCommon/selectors.ts 0.00% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #9733      +/-   ##
==========================================
- Coverage   37.82%   37.81%   -0.02%     
==========================================
  Files         994      994              
  Lines       91126    91166      +40     
  Branches     1176     1176              
==========================================
+ Hits        34470    34475       +5     
- Misses      56202    56237      +35     
  Partials      454      454              
Flag Coverage Δ
editoast 72.99% <ø> (-0.03%) ⬇️
front 20.12% <31.81%> (+<0.01%) ⬆️
gateway 2.18% <ø> (ø)
osrdyne 3.28% <ø> (ø)
railjson_generator 87.49% <ø> (ø)
tests 86.74% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@anisometropie anisometropie force-pushed the vcs/fix-block-pathfinding-called-twice branch from b2913ba to 8acddb2 Compare November 19, 2024 13:33
@anisometropie anisometropie changed the title partial fix front: call pathfinding only once Nov 19, 2024
@anisometropie anisometropie marked this pull request as ready for review November 19, 2024 13:34
@anisometropie anisometropie requested a review from a team as a code owner November 19, 2024 13:34
@emersion
Copy link
Member

Hm, won't this result in a pathfinding being started on stale data, and the latest via change will get ignored?

Comment on lines 199 to 215
if (pathfindingState.running) {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to fix the symptom but not the underlying issue.

@anisometropie
Copy link
Contributor Author

Hm, won't this result in a pathfinding being started on stale data, and the latest via change will get ignored?

from the test I have run, haven’t seen a case where it doesn’t use the latest data

@emersion
Copy link
Member

What about this case:

  • User sets a via
  • Pathfinding starts, takes some time
  • User changes their mind, sets another via
  • Reply to the first pathfinding comes back

Latest user change is ignored here.

I'd argue correctness (user input not ignored) is more important than performance (1 pathfinding request instead of 2).

@anisometropie anisometropie force-pushed the vcs/fix-block-pathfinding-called-twice branch 4 times, most recently from 012b40d to 6e08dde Compare November 21, 2024 15:23
@anisometropie anisometropie force-pushed the vcs/fix-block-pathfinding-called-twice branch from 6e08dde to 9459907 Compare November 21, 2024 16:55
@github-actions github-actions bot added the area:front Work on Standard OSRD Interface modules label Nov 21, 2024
@@ -209,6 +226,12 @@ export const usePathfinding = (
}, [vias]);

useEffect(() => {
if (
(previousOrigin !== origin || previousDestination !== destination) &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is enough: an intermediary waypoint might've changed too, or rolling stock, or something else…

But, what is the root cause? Why does pathfinding run twice, which state change causes this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

intermediary waypoint don’t do aything in this useEffect, and rolling don’t create the bug.

Root cause is pathfinding updating vias when it succeeds. So we need to ignore exactly one call made and resume listening after, which is what pathStepsCompletedWithPF does

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably gonna change after the refacto #9924

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:front Work on Standard OSRD Interface modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pathfinding launched two times when adding a via
4 participants