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

(#1322) Fix crashes in test case PushTests.test__008__LocalDevice__has_a_device_method_that_returns_a_LocalDevice (4f837671-6233-41f1-94e8-01174d1da7b8) #1388

Conversation

lawrence-forooghian
Copy link
Collaborator

@lawrence-forooghian lawrence-forooghian commented May 4, 2022

What does this do?

Introduces various concurrency-related fixes related to the local device. Together, I believe these fix various crashes that we've observed in the test mentioned in the title (#1322). See commit messages for more details.

How do I know it's fixed the test?

These are the results of the tests running continuously with these fixes applied. At time of writing, there are 97 test runs with no failures in this test, but I'll keep it running for a while more before merging.

@lawrence-forooghian lawrence-forooghian added bug Something isn't working. It's clear that this does need to be fixed. test-stability and removed bug Something isn't working. It's clear that this does need to be fixed. labels May 4, 2022
@lawrence-forooghian lawrence-forooghian force-pushed the 1322-fix-test-case-4f837671-6233-41f1-94e8-01174d1da7b8-take-3 branch from 5aeb990 to e19e037 Compare May 4, 2022 18:25
We currently read / write the variable that stores the shared
ARTLocalDevice variable from the internal queue of the ARTRest instance
through which the device is being accessed. But, since each ARTRest
instance has its own queue, this means that access to this variable
isn’t currently synchronised between multiple ARTRest instances.

So, here we do that.

This also allows us to remove our usage of dispatch_once. This is a good
thing, because we were using it incorrectly before. From an Apple
engineer on https://stackoverflow.com/a/19845164:

> The implementation of dispatch_once() requires that the
> dispatch_once_t is zero, and has never been non-zero.

That is, you can’t reset a dispatch_once_t variable and expect
dispatch_once to still work with it, which is what we were doing.
This doesn’t change anything, it just explains the current behaviour of
the code.

ARTLocalDeviceStorage already conforms to these requirements, since it
uses the (already thread-safe) user defaults / keychain. However,
MockDeviceStorage does need some synchronisation. I’ll do that next.
As promised in e0ff029.

Together with de281bd and fbd5645, I believe this closes #1322 (various
crashes in
PushTests.test__008__LocalDevice__has_a_device_method_that_returns_a_LocalDevice,
which seemed to be related to threading).

Test case:
https://test-observability.herokuapp.com/repos/ably/ably-cocoa/test_cases/4f837671-6233-41f1-94e8-01174d1da7b8
@lawrence-forooghian lawrence-forooghian force-pushed the 1322-fix-test-case-4f837671-6233-41f1-94e8-01174d1da7b8-take-3 branch from e19e037 to 280a236 Compare May 4, 2022 18:28
@lawrence-forooghian lawrence-forooghian marked this pull request as ready for review May 5, 2022 14:54
@lawrence-forooghian
Copy link
Collaborator Author

D'oh, put the wrong issue number. Gonna open a new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant