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

APP-3318 - Fix sticky motor slider #153

Merged
merged 5 commits into from
Dec 1, 2023

Conversation

clintpurser
Copy link
Member

On Plus/Max sized iphones, the call to set state after awaiting setPower would happen sometimes after the call to stop had gone through, causing the slider to stick after release, even when the toggle to stop after release was enabled.

Moving the setState to before the awaited method calls fixes this issue.

I considered making the calls to setPower and stop unawaited() - but then we'd lose our error handling from the try catch.

We could also use the older convention of not using async/await and instead use the Future.onError() callback, to populate the error object. But I opted for using async and await because they are more idiomatic.

@clintpurser clintpurser requested a review from njooma November 30, 2023 15:25
@clintpurser clintpurser requested a review from a team as a code owner November 30, 2023 15:25
Copy link
Member

@benjirewis benjirewis left a comment

Choose a reason for hiding this comment

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

I swear I've seen this "setPower interacts weirdly with setState(() { this.power = power });" in one of @njooma's old reviews. Don't have much context here but seems fine to me.

@clintpurser
Copy link
Member Author

I swear I've seen this "setPower interacts weirdly with setState(() { this.power = power });" in one of @njooma's old reviews. Don't have much context here but seems fine to me.

You're right @benjirewis it does sound familiar. I hope we're not punting different bugs back and forth by changing the order around.

Copy link
Member

@njooma njooma left a comment

Choose a reason for hiding this comment

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

Just a Q, but LGTM otherwise

Comment on lines 52 to 53
await widget.motor.setPower(0);
await widget.motor.stop();
Copy link
Member

Choose a reason for hiding this comment

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

Do we need both here?

Copy link
Member Author

@clintpurser clintpurser Nov 30, 2023

Choose a reason for hiding this comment

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

good call out, probably merits a comment if we keep it in.

I added both as a stop gap in case this the motor was a module with stop() unimplemented.

thinking through it now, it does seem unneeded. 🤔

@clintpurser clintpurser merged commit 49cb251 into viamrobotics:main Dec 1, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants