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

Support ARTPushRegistererDelegate on iOS 14 #1075

Merged
merged 9 commits into from
Oct 16, 2020

Conversation

QuintinWillison
Copy link
Contributor

Fixes #1069.

…egate.

- removes exceptions which should never have been thrown from within the machine.
- simplifies optional method checks by requesting NSObject protocol conformance.
- removes impotent __block storage qualifiers.
@QuintinWillison QuintinWillison self-assigned this Oct 6, 2020
@QuintinWillison
Copy link
Contributor Author

So far this PR just presents the groundwork. The next step is to offer an alternative route for actively injecting the delegate.

Quintin Willison added 3 commits October 7, 2020 14:04
The Carthage workaround we're using, in lieu of this either being fixed in Carthage or us throwing Carthage out of our mix:
Carthage/Carthage#3019 (comment)

I've also added --no-use-binaries to our Makefile which will result in less compatibility issues, albeit at the cost of greater build at times. Inspired by:
https://medium.com/wolox/how-to-carthage-efficiently-4913b8378898
@QuintinWillison
Copy link
Contributor Author

QuintinWillison commented Oct 7, 2020

Good progress today but still a way to go. We're now building and running tests successfully in Xcode 12. Remaining to do, as far as I'm aware:

  • Fix new warnings raised by Xcode 12's build
  • Add and implement new interface for supplying delegate

Source/ARTPush.m Outdated Show resolved Hide resolved
Source/ARTPush.m Outdated Show resolved Hide resolved
Source/ARTPush.m Outdated Show resolved Hide resolved
Variable was never mutated; consider changing to 'let' constant.
Variable was never used; consider replacing with '_' or removing it.
Value was defined but never used; consider replacing with boolean test.
NSData cast is unnecessary.
Predicate.fromDeprecatedClosure is deprecated.
@ricardopereira
Copy link
Contributor

Screenshot 2020-10-15 at 18 29 12

@ricardopereira ricardopereira marked this pull request as ready for review October 15, 2020 17:33
@lawrence-forooghian
Copy link
Collaborator

I say 🎉 to the fact that:

I’ve had to spend quite a bit of time looking at this PR to roughly understand what’s going on here. A large amount of this is definitely because I’m new to the company, the codebase, and the problem space. But I also think that we could spend a bit of time thinking about how this PR is presented, to see whether it could be made friendlier for reviewers, and whether there’s anything we might want to think about when we present our work for code review in the future. I found myself doing quite a lot of guesswork to understand the intent behind the various components of this PR.

I’ll try and explain my thought process. I realise that I’ve spent more time here commenting on the structure of the PR than engaging with its exact contents. And if I’ve completely misunderstood what's going on here and wasted a bunch of people's time, then I'm very sorry.

How have we fixed #1069?

The PR description says that it fixes issue #1069. So I was a little surprised to see that there was no further mention of what we’ve done to fix this particular issue - neither in the pull request description nor the commit messages.

Issue #1069 describes a symptom - a library user’s app is crashing when the app delegate is instantiated in a specific manner new to iOS 14. Before we can fix the symptom, I think we first need to understand the underlying cause. The user who raised the issue has offered their speculation as to the cause (“I believe UIApplicationDelegateAdaptor is downcasting MyAppDelegate to UIApplicationDelegate”) but I think our first action should be to confirm whether this is true, and if it isn’t then to identify the actual cause.

This probably requires us to begin by reproducing the issue ourselves. I did a little bit of investigation here, creating a test app to see how protocol conformance of the app delegate is affected by UIApplicationDelegateAdaptor. The reporter of the issue isn’t too far from the truth - when this property wrapper is used, SwiftUI creates an app delegate of its own special internal class SwiftUI.AppDelegate, which in some way wraps an instance of the MyAppDelegate class. The important fact is that it wraps it in a way which preserves the methods which the app delegate responds to, but does not preserve protocol conformance. Perhaps you knew all of this already, but this is definitely useful context and motivation for the changes of this PR, and I think it would be very valuable to include in a commit message.

Have we fixed #1069 in two different ways?

It seems to me like the very first commit of this pull request (cc03343) by itself would have fixed the issue reported in #1069, given the underlying cause explained above.

With that in mind, I’m a little confused about why we then build functionality that allows a push registerer delegate to be passed in to the SDK, instead of using the application’s sharedDelegate. I’m not saying that it isn’t a good idea - indeed, it seems like quite a good one from a “don’t mess with singletons you didn’t create” point of view. But it would be great if the commit messages could help (a reviewer / future new developers / future us) understand the motivation for this additional code - why is it required in order to fix #1069?

Why is this PR the right place to get the SDK working with Xcode 12?

So, it seems like this PR has three main themes:

  1. Fix Push Notification Registration via ARTPushRegistererDelegate don't work in iOS 14 when instantiated via @UIApplicationDelegateAdaptor #1069 (possibly in a couple of different ways);
  2. Get the codebase working with Xcode 12, for some value of “working” which I’m keen to understand better;
  3. Drop support for iOS 8.

It’s not 100% clear to me why these three things are in the same PR. And I mean that in the following senses:

  • Getting things working with Xcode 12 seems like a large enough and self-contained enough change that it deserves its own PR. That PR would be a great space to help reviewers understand what exactly it is that’s now working (see sub-heading below).
  • Similarly, I’m guessing there’s some context (possibly a business decision) behind the decision to drop iOS 8 support. That context could be captured in a commit message and I think would sit well in its own PR.
  • How does getting the app building in Xcode 12 help us to fix Push Notification Registration via ARTPushRegistererDelegate don't work in iOS 14 when instantiated via @UIApplicationDelegateAdaptor #1069? I’m guessing that it’s because we wanted to (manually?) test that we’ve fixed the issue by building an app with the iOS 14 SDK, using UIApplicationDelegateAdaptor, and confirming that the crash doesn’t happen. But I struggle to understand the connection by purely looking at the contents of the PR.

What exactly is now working, Xcode 12-wise?

As I said above, I get the sense from this PR that there is a theme of “make the SDK work on Xcode 12”. But what does that mean? And what doesn’t it mean? There are quite a few things that one might reasonably expect to be included in a “make it work on Xcode 12” set of changes. For example:

  • It can now be built with Xcode 12, where it couldn't before?
  • The tests are passing when running on Xcode 12, where they weren’t before?
  • There is now some sort of support for iOS 14 that there wasn’t before?
  • We’re now using Xcode 12 to build for CI?

I think that if there were a separate PR for the Xcode 12 changes, then that would give us a chance to explore which of these we have and haven’t done, and why. And hence tells reviewers which things have been accidentally missed and which things the PR submitter has deliberately left outstanding, so the reviewer knows where to focus their attention.

A few other comments on commit structure

I’m approaching the commit structure from a “how could this be more reviewable” point of view here.

  • Definitely a subjective one, but I think that commits a78d0f3, 888e564, 26a5e43 could go into a single commit - “Push registerer delegate can be explicitly specified” or something like that. Particularly with 888e564 and 26a5e43 - new functionality and the tests for it are probably a single logical change.
  • Commit b66cc4c8 is just an alteration to some changes introduced in 888e564, so I don’t think it warrants its own place in the commit history. Instead we could rebase and fixup the original commit. (If this is something that you’re not in the habit of doing, I’m happy to go into more detail about this sort of workflow.)
  • Commit 30e149d (“Remove warnings from test suite”) - where have these warnings come from, and why are we fixing them here? Are they warnings that appear when building in Xcode 12, for example?

Copy link
Collaborator

@lawrence-forooghian lawrence-forooghian left a comment

Choose a reason for hiding this comment

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

(Leaving this comment so that the review request is marked as actioned. My above comment is my review, but I had to leave it as a normal comment because it was too long for a review comment.)

@ricardopereira ricardopereira self-requested a review October 16, 2020 08:36
@QuintinWillison
Copy link
Contributor Author

Thanks @lawrence-forooghian! 😁 I don't disagree with anything you've said. We will get better at this.
(internal conversation expanding on this)

@QuintinWillison QuintinWillison merged commit 0768224 into main Oct 16, 2020
@QuintinWillison QuintinWillison deleted the feature/1069-push-registerer-delegate branch October 16, 2020 09:05
maratal pushed a commit that referenced this pull request Jul 19, 2023
Fixed channel detach spec for RTL5h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants