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

Made the choice set manager thread safe #1603

Merged

Conversation

NicoleYarroch
Copy link
Contributor

@NicoleYarroch NicoleYarroch commented Mar 25, 2020

Fixes #1584

This PR is ready for review.

Risk

This PR makes no API changes.

Testing Plan

  • I have verified that I have not introduced new warnings in this PR (or explain why below)
  • I have run the unit tests with this PR
  • I have tested this PR against Core and verified behavior (if applicable, if not applicable, explain why below).

Unit Tests

Added test cases to the SDLChoiceSetManagerSpec to verify that the list of pending and uploaded choice items is not updated after the choice set manager is shutdown. This can happen if the transport is destroyed while choice items are being preloaded, deleted or presented.

Core Tests

  1. Checked that destroying the transport while choices are being preloaded does not break the choice set manager when the transport is reestablished.
  2. Checked that destroying the transport while choices are being presented does not break the choice set manager when the transport is reestablished.
  3. Check that destroying the transport while the keyboard is being presented does not break the choice set manager when the transport is reestablished.

Core version / branch / commit hash / module tested against: SYNC 3.0
HMI name / version / branch / commit hash / module tested against: SYNC 3.0

Summary

Made the choice set manager thread safe.

Changelog

Bug Fixes
  • Fixed the library crashing due to multiple threads accessing NSMutableSets at the same time.
  • Made setting the choice set ids thread safe, so no two choices can be assigned the same choiceId or cancelId.
  • Fixed the choice set manager failing to present a choice set due to an INVALID_ID. This was due to adding choice set items to the list of pending and presenting choice items after the transport was destroyed. Since the library thought those choice items were on the module, they were not uploaded, thus creating an error when trying to present the choice set items.

Tasks Remaining:

  • Unit tests
  • Smoke tests

CLA

@NicoleYarroch NicoleYarroch added bug A defect in the library manager-screen Relating to the manager layer - screen managers labels Mar 25, 2020
@NicoleYarroch NicoleYarroch self-assigned this Mar 25, 2020
@NicoleYarroch NicoleYarroch added this to In progress in v6.6.0 via automation Mar 25, 2020
@NicoleYarroch NicoleYarroch changed the title WIP: Made the choice set manager thread safe Made the choice set manager thread safe Mar 27, 2020
SmartDeviceLink/SDLChoiceSetManager.m Show resolved Hide resolved
SmartDeviceLink/SDLChoiceSetManager.m Outdated Show resolved Hide resolved
SmartDeviceLink/SDLChoiceSetManager.m Outdated Show resolved Hide resolved
SmartDeviceLink/SDLChoiceSetManager.m Outdated Show resolved Hide resolved
SmartDeviceLink/SDLChoiceSetManager.m Outdated Show resolved Hide resolved
SmartDeviceLink/SDLChoiceSetManager.m Show resolved Hide resolved
SmartDeviceLink/SDLChoiceSetManager.m Show resolved Hide resolved
SmartDeviceLink/SDLChoiceSetManager.m Outdated Show resolved Hide resolved
SmartDeviceLink/SDLChoiceSetManager.m Show resolved Hide resolved
SmartDeviceLink/SDLChoiceSetManager.m Show resolved Hide resolved
v6.6.0 automation moved this from In progress to Waiting for Review Mar 31, 2020
SmartDeviceLink/SDLChoiceSetManager.m Show resolved Hide resolved
SmartDeviceLink/SDLChoiceSetManager.m Outdated Show resolved Hide resolved
NicoleYarroch and others added 3 commits April 2, 2020 11:55
Co-Authored-By: Joel Fischer <joeljfischer@gmail.com>
SDLLogD(@"Finished deleting choices");
[weakself.preloadedMutableChoices minusSet:cellsToBeDeleted];
// Check if the manager has shutdown because the list of uploaded choices should not be updated
if ([strongSelf.currentState isEqualToString:SDLChoiceManagerStateShutdown]) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instead of checking the state here and in other blocks, we could just "reset" all the properties in the start method.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure what you mean by that. Why would resetting properties in start help? They're already reset in didEnterStateShutdown.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is that the didEnterStateShutdown is called and all the properties reset before the completion block is called for the choice set upload. Then in the completion block, some of the properties are set.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I gotcha. I think this is a better way to do it. Better not to set the properties at all than to have to reset them later. If a dev checks them while it's shut down it'll show the wrong data.

v6.6.0 automation moved this from Waiting for Review to Reviewer approved Apr 3, 2020
@joeljfischer joeljfischer merged commit 4f650ef into develop Apr 3, 2020
v6.6.0 automation moved this from Reviewer approved to Done Apr 3, 2020
@joeljfischer joeljfischer deleted the bugfix/issue_1584_choice_set_manager_not_thread_safe branch April 3, 2020 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A defect in the library manager-screen Relating to the manager layer - screen managers
Projects
No open projects
v6.6.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants