Skip to content
This repository has been archived by the owner on Aug 14, 2019. It is now read-only.

Hits KVO exception breakpoint every time #285

Closed
RishabhTayal opened this issue May 14, 2014 · 30 comments · Fixed by #304
Closed

Hits KVO exception breakpoint every time #285

RishabhTayal opened this issue May 14, 2014 · 30 comments · Fixed by #304
Labels

Comments

@RishabhTayal
Copy link

I have a Exception breakpoint in my project. The breakpoint hits line 155 in JSQMessagesInputToolbar everytime. Method name is 'jsq_removeObservers'.

Not a big issue, but it would be better to know the solution to avoid this.

Thanks.

@jessesquires
Copy link
Owner

this exception is caught and handled.

what we need is a way to ask if a key-value observer has been previously added, but that does not exist in the API. :(

@khanlou
Copy link

khanlou commented May 20, 2014

I'd like to request that this be reopened. Leaving the Objective-C Exception Breakpoint turned on by default is extremely useful for debugging. Is it possible to use KVOController to handle the automatic addition and removal of observers for the view controller, or possibly to balance these calls so that an observer is never removed twice? I'm happy to submit a patch if you're amenable to it.

@RishabhTayal
Copy link
Author

I agree. It is really annoying when exception breakpoint is enabled.

@jessesquires
Copy link
Owner

@khanlou / @RishabhTayal 👍 re-opened.

@jessesquires jessesquires reopened this May 20, 2014
@khanlou
Copy link

khanlou commented May 20, 2014

Awesome. Let me know if you want me to write a patch and pull request it.

@jessesquires
Copy link
Owner

@khanlou - please do!

@jessesquires
Copy link
Owner

fixed in PR #304

@rnaud
Copy link

rnaud commented Jun 19, 2014

I am still seeing the issue in version 5.0.4, am I missing something?

@RishabhTayal
Copy link
Author

The issue is still there. :(

@khanlou
Copy link

khanlou commented Jun 19, 2014

@rnaud it was rolled back due to some inconsistencies. i haven't had a chance to fix them yet, not sure if i will get a chance

@jessesquires
Copy link
Owner

because of how view{Will/Did}(Appear/Disappear} in iOS 7 with UINavigationController, it is extremely difficult, if not impossible to "get this right".

there are lots of edge cases, and when i was writing this i could not find a good way to implement balanced calls to add/remove observers.

this is a major deficiency in Apple's API -- the lack of ability to check if an observer has already been added or not. 😢

@jessesquires jessesquires reopened this Jun 19, 2014
@rnaud
Copy link

rnaud commented Jun 19, 2014

This is more of an annoyance than a bug anyway, the lib is great.

@jessesquires jessesquires changed the title Hits exception breakpoint every time. Hits KVO exception breakpoint every time Jun 19, 2014
@eusthace811
Copy link

Hi Guys, any news about this issue? It happens all the time, please, any help?

@jessesquires
Copy link
Owner

@jlsuarezs - see my comment above and the discussion in the PR itself.

@eusthace811
Copy link

Hi Jesse!!, I have read it, but that means we can not use the latest version of your component?
:-(
Ohhh, It was so cool! :-'(

@jessesquires
Copy link
Owner

@jlsuarezs - i don't understand. why do you think you can't use it?

@RishabhTayal
Copy link
Author

@jessesquires Do you think this would solve the issue?
https://github.com/facebook/KVOController

@jessesquires
Copy link
Owner

@RishabhTayal - I've been thinking about that! When I have a chance, I'll try it out.

@RishabhTayal
Copy link
Author

@jessesquires I have created a pull request which fixes this issue. Please review the code and accept it.

@jessesquires
Copy link
Owner

@RishabhTayal - when i have time!

@wdcurry
Copy link

wdcurry commented Jun 26, 2014

How about all of us chip in and donate to Jesse to both thank him and incentivize him :)

@markkrenek
Copy link

Why not just create a bool ivar that tracks when the KVO observer has been installed? Use the ivar to determine whether or not to remove the observer. That's the simple fix I've put in place for myself. I'm not proficient at pull requests, so I can't provide one.

In JSQMessagesInputToolbar.m & JSQMessagesViewController.m, I added

@property (nonatomic, assign) BOOL isObserving;

In jsq_addObservers, check that isObserving is NO before proceeding, and set isObserving to YES once the observers are installed.

Similarly in jsq_removeObservers, check that isObserving is YES before proceeding, and set isObserving to NO once the observers have been removed.

@jessesquires
Copy link
Owner

@markkrenek - excellent suggestion!

@chrisballinger
Copy link
Collaborator

I would also like to see this issue resolved either with KVOController or with the bool ivar (if it works)

@jessesquires
Copy link
Owner

@chrisballinger - planned for the next release 👍

@chrisballinger
Copy link
Collaborator

Awesome! :)

On Wednesday, July 16, 2014, Jesse Squires notifications@github.com wrote:

@chrisballinger https://github.com/chrisballinger - planned for the
next release [image: 👍]


Reply to this email directly or view it on GitHub
#285 (comment)
.

@mbcoder17
Copy link

This is still an issue for me. It only happens the first time I load my chat view, and it still happens on line 155. I just re-downloaded the entire library and replaced my files just to be sure, but it still happens :/

@jessesquires
Copy link
Owner

@mbcoder17 - i can't repro.

is anyone else still seeing this issue?

/cc: @chrisballinger @RishabhTayal @markkrenek @khanlou

@mbcoder17
Copy link

My app is managed by a tab controller, this wouldn't have something to do with the issue, would it? It's weird that it only happens after I build from xcode. After that it doesn't happen, but when I build again it does, only the first time...

@mbcoder17
Copy link

@jessesquires I also want to add that line 155 is empty lol, could it be hitting a breakpoint or something?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
9 participants