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

Deregister notification observers and listeners before application termination #301

Merged
merged 6 commits into from
Aug 2, 2018

Conversation

fractalwrench
Copy link
Contributor

@fractalwrench fractalwrench commented Jul 31, 2018

Goal

Deregister any listeners or observers when the app is about to terminate, to prevent allocations from occurring during dealloc.

Changeset

  • Update Podfiles for example apps to latest version
  • Add an observer for termination notifications for each platform
  • Remove all notification observers when a termination notification is received
  • Stop watching connectivity changes when about to terminate
  • Stop watching orientation/battery monitoring when about to terminate

Tests

Ran the iOS and macOS example apps and confirmed the stop method was invoked, and that no crashes were detected on exiting the application

Review

For the submitter, initial self-review:

  • Commented on code changes inline explain the reasoning behind the approach
  • Reviewed the test cases added for completeness and possible points for discussion
  • A changelog entry was added for the goal of this pull request
  • Check the scope of the changeset - is everything in the diff required for the pull request?
  • This pull request is ready for:
    • Initial review of the intended approach, not yet feature complete
    • Structural review of the classes, functions, and properties modified
    • Final review

For the pull request reviewer(s), this changeset has been reviewed for:

  • Consistency across platforms for structures or concepts added or modified
  • Consistency between the changeset and the goal stated above
  • Internal consistency with the rest of the library - is there any overlap between existing interfaces and any which have been added?
  • Usage friction - is the proposed change in usage cumbersome or complicated?
  • Performance and complexity - are there any cases of unexpected O(n^3) when iterating, recursing, flat mapping, etc?
  • Concurrency concerns - if components are accessed asynchronously, what issues will arise
  • Thoroughness of added tests and any missing edge cases
  • Idiomatic use of the language

…on is received

Previously observers and listeners were not deregistered when the application terminated. This is
hypothesised to lead to allocations during dealloc, which could lead to rogue memory writes.
@fractalwrench fractalwrench changed the base branch from master to next July 31, 2018 13:01
@fractalwrench fractalwrench requested a review from a team July 31, 2018 13:03
/**
* Removes observers and listeners to prevent allocations when the app is terminated
*/
- (void)stop:(id)sender {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd name this a bit more verbosely, like unsubscribeFromNotifications. There is an off chance that with a name like stop, it could be picked up erroneously in app review as a private API usage.

@fractalwrench fractalwrench merged commit ecd262e into next Aug 2, 2018
@fractalwrench fractalwrench deleted the deregister-notification-observers branch August 2, 2018 08:01
@fractalwrench fractalwrench restored the deregister-notification-observers branch August 3, 2018 07:30
@fractalwrench fractalwrench deleted the deregister-notification-observers branch August 24, 2018 10:07
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.

2 participants