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

Crashing on changing orientation while UISearchController is active #51

Closed
Idomo opened this issue Oct 24, 2018 · 8 comments · Fixed by #71
Closed

Crashing on changing orientation while UISearchController is active #51

Idomo opened this issue Oct 24, 2018 · 8 comments · Fixed by #71

Comments

@Idomo
Copy link
Contributor

Idomo commented Oct 24, 2018

Hi,
I tried using your library, it's looking very nice, but has a little problem when changing the device orientation while the navigationItem.searchController.isActive = true.
This is the error I'm getting in the console:

*** Assertion failure in -[HGPlaceholders.TableView _classicHeightForRowAtIndexPath:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore/UIKit-3698.84.16/UITableView.m:15329
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid row height provided by table delegate. Value must be at least 0.0, or UITableViewAutomaticDimension.'

After some debugging I'v noticed that the hight from the delegate is -119:
image
So I tried the most obvious thing, I'v added tableViewHeight = tableViewHeight >= 0.0 ? tableViewHeight : UITableView.automaticDimension before the method return (line 154), but guess what?
Somehow the value is still -119 😓
So I thought maybe the UITableView.automaticDimension is also returning -119? so let's try just tableViewHeight = 0.
No, it didn't worked, tableViewHeight was still -119. 😧

Hope you'll be able to reproduce and detect how to solve this problem.
I didn't understand yet how is that possible to change the value by this way (tableViewHeight = 0) and it won't change, like this line doesn't exists. 😨

Thanks,
Ido.

@Idomo
Copy link
Contributor Author

Idomo commented Oct 31, 2018

@HamzaGhazouani
After more checking I'v noticed it's happening only when changing the orientation while the keyboard is active, otherwise it won't crash.

One more thing I'v noticed for is that the tableView(_tableView:, heightForRowAt indexPath:) in PlaceholderDataSourceDelegate is getting called a lot of times (some times it was about 20 times) although only one operation (like changing orientation or setting searchController to be active) has been performed.

Hope you'll be able to find solution for this, 'cause it's very critical issue.
Thanks,
Ido.

@HamzaGhazouani
Copy link
Owner

@Idomo Thanks for reporting, I will look at it asap, If you find a fix don't hesitate to create a PR, thanks

@Idomo
Copy link
Contributor Author

Idomo commented Nov 29, 2018

@HamzaGhazouani I wish I would be able to fix this, my app is on the App Store for about a month and I don’t want users to stop using it only because of this crash.
Hope you’ll be able to fix this ASAP.

@Idomo
Copy link
Contributor Author

Idomo commented Jan 20, 2019

HI @HamzaGhazouani and @jamchen @monkeywithacupcake @Brusnikin (May you'll be able to resolve this),
There is any progress with this issue? it's kinda old and pretty big one.
So far no one that using my app has been reported to me about it, but I don't want to wait for someone to do so.

@Idomo
Copy link
Contributor Author

Idomo commented Sep 16, 2019

@HamzaGhazouani I'd like to release an update with bug fixes to my app, this is pretty much in my top priority right now, so please, help me with this one.
*I can reproduce this also on iOS 13 (with real device).

@monkeywithacupcake
Copy link
Contributor

I cannot reproduce this error.

@Idomo
Copy link
Contributor Author

Idomo commented Dec 3, 2019

I cannot reproduce this error.

On which iOS version and device (simulator/real and model)?

Idomo added a commit to Idomo/HGPlaceholders that referenced this issue Jan 11, 2022
Fix HamzaGhazouani#51 
From some reason, the fix I've tried a long time ago with iOS 13 and didn't work, now working with iOS 15.
@Idomo
Copy link
Contributor Author

Idomo commented Jan 11, 2022

@HamzaGhazouani Finally, after a 3.5 years, the issue has been solved!
You may merge #71 (and the rest of the PRs that seems to be forgotten) and release some update.

@Idomo Idomo closed this as completed Jan 11, 2022
HamzaGhazouani pushed a commit that referenced this issue Jan 13, 2022
* Make sure `tableViewHeight` isn't less then 0.0 to prevent crash

Fix #51 
From some reason, the fix I've tried a long time ago with iOS 13 and didn't work, now working with iOS 15.

* Fix deprecated code

Fix warning: Using 'class' keyword to define a class-constrained protocol is deprecated; use 'AnyObject' instead

* Fix deprecated code

* Fix deprecated code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants