今是昨非

今是昨非

日出江花红胜火,春来江水绿如蓝

Problems Encountered During Development (Part 2)

Problems Encountered in Development, Shared with Everyone, Improve If Possible.#

1. The Crash Issue Caused by Adding a 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.

Cause:#

It is 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 no one reported them, 😓, probably no one had any complaints... Apple didn't expect it either, so we went online, and then there were crashes... This is so frustrating.

Solution:#

Since there is this issue, it needs to be resolved. The most frustrating part of using this category is that even if you didn't import this header file, there may still be conflicts with it in other input areas, causing crashes... So the problem is still very serious!!! The solution is very simple, delete this category and implement keyboard dismissal in a different way. For specific details, 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 webpage in a webView: NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)#

Yesterday, I added a new entry point to a page. When clicked, it would redirect to a webpage and the login status needed to be passed to the webpage. After completing it, today during testing, it was found that the redirected webpage was fine, but adding items to the shopping cart didn't work, and clicking on the "Personal Center" tag at the bottom of the webpage didn't have any response...

Identifying the Cause:#

Check how it is displayed on Android, whether it can be redirected, everything is normal...
Then start troubleshooting,
a. Is the login status not being passed to the webpage?
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 is different between the URLs that can be redirected and the ones that can't.
There really was a difference. The URLs that can be redirected are all HTTP requests, and the "Personal Center" originally was also HTTP, but after the request, there was a redirection (automatic redirection) to HTTPS; and then the problem occurred, triggering the webView's loading failure method, and the printed error was

NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)

So, why is this happening? Take a look at the situation of this HTTPS link in the browser, it shows that the certificate has expired and it is an insecure link.
d. Baidu, uh, don't be noisy, it really was Baidu...

Conclusion:#

It seems that the certificate in the testing environment was created by the backend and it has expired, so this problem occurred.

Solution:#

There are three possible solutions for this:
One is for the backend to update the certificate and bring over a good and trusted certificate;
The second is for the client to modify the code and block the insecure one; but it would be best to differentiate between going online and testing, remove these when going online, otherwise, this HTTPS would be meaningless.
The last one is for everyone to not make any changes, and testing should not test this, anyway, it works fine online... 😄
Don't ask me which one I used...

If the client wants to make modifications, refer to iOS UIWebView Loading HTTPS Site Causes NSURLConnection/CFURLConnection HTTP load failed (kCFStreamE..., I haven't tried it, it seems to expose something...

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.