Problems Encountered in Development, Shared with Everyone, Improve If Possible.#
1. Crash Issue Caused by Adding Category to UIScrollView - [UIKBBlurredKeyView candidateList]#
Last week, the updated application was released, and it went online this week. Then yesterday, a colleague next to me told me that the crash rate on Umeng was over 1%. I quickly checked it out.
After taking a look, I found that most of the crashes had this log: [UIKBBlurredKeyView candidateList]: unrecognized selector sent to instance..., so I searched for it
Crash Reproduction:#
Switch to a place with input, click to input, switch the input method to handwriting input method (system's, third-party ones are fine), and then input. After inputting one character, the second character will cause a crash.
Reason:#
It's because a category was added to UIScrollView, which is used to handle screen touch events (to dismiss the keyboard when touching the screen). We have been doing it this way before, and there were no issues, or maybe there were issues but nobody reported them, 😓, probably no one complained... And we didn't test handwriting input method because no one would think there would be any difference. Apple didn't think of it either, so we went online, and then there were crashes... This is so frustrating.
Solution:#
Since there is this issue, we need to solve it. The most frustrating thing about using this category is that even if you didn't import this header file, it may still conflict with other input areas and cause crashes... So the problem is still very serious!!! The solution is very simple, delete this category and find another way to implement keyboard dismissal. Please refer to this blog post [UIKBBlurredKeyView candidateList]: unrecognized selector sent to instance 0x177cc850, that's how I fixed it.
2. This Error Occurred When Loading a Web Page in a webView - NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)#
Yesterday, I added a new entry point to a page. When clicked, it would navigate to a web page and the login status needed to be passed to the web page. After finishing it, we started testing it today, and the testers found that the web page could not add items to the shopping cart, and clicking on the "Personal Center" label at the bottom of the web page had no response...
Identifying the Cause:#
Let's see how it appears on Android, if it can navigate properly... It's normal...
Then we started troubleshooting,
a. Is the login status not being passed to the web page?
b. Is it a problem with the phone? Can this URL be opened directly from the browser?
After ruling out these two possibilities, there was no way,
c. Print step by step to see what's different between the URLs that can navigate properly and the ones that can't.
There really was a difference, the URLs that can navigate properly are all HTTP requests, and the "Personal Center" originally was also HTTP, but after the request, there was a redirect (automatic redirection) to HTTPS; and then the problem occurred, it went into the webview's loading failure method, and the printed error was
NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
So, why is that? Let's take a look at the situation of this HTTPS link in the browser, it shows that the certificate has expired and it's an insecure link.
d. Baidu, um, don't be noisy, it really is Baidu...
Conclusion:#
It's because the certificate in the testing environment seems to have been created by the backend and it has expired, so this problem occurs.
Solution:#
There are three possible solutions for this:
One is for the backend to update the certificate and bring over a trusted certificate;
The second is for the client to modify the code and disable the insecure one; but it's best to differentiate between going online and testing, remove these when going online, otherwise this HTTPS is meaningless.
The last one is for everyone to not make any changes, and testers should not test this, anyway it's fine in the production environment... 😄
Don't ask me which one I used...
If the client wants to make modifications, please refer to iOS UIWebView Loading HTTPS Site Causes NSURLConnection/CFURLConnection HTTP load failed (kCFStreamE..., I haven't tried it, it seems to expose something...