nicklockwood / FXBlurView

[DEPRECATED]
Other
4.94k stars 713 forks source link

Multiple error with CGContextRestoreGState #9

Closed ldesroziers closed 11 years ago

ldesroziers commented 11 years ago

Since I use FXBlurView, I'm getting multiple CGContextRestoreGState errors in the console:

<Error>: CGContextRestoreGState: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context  and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
ldesroziers commented 11 years ago

If it helps, seems like -snapshotOfSuperview: is responsible of this bug. But as i'm currently using the SDK 7.0b, it may comes from the SDK itself and the -renderInContext: method...

nicklockwood commented 11 years ago

I think it happens when your view has a size of zero. I thought I'd fixed it, but apparently not.

Try ensuring that your FXBlurView frame is set before you add it to the screen.

ldesroziers commented 11 years ago

I don't think it's the problem (I mean, you clearly have fixed it). This log shows every time I scroll (and thus every time the blurView is updated) and I got only 2 blurView above that scrollView, both have a non-zero size. Once I remove them from screen, no more logs appear.

nicklockwood commented 11 years ago

Hmm. Okay, I'll investigate further. If you can reproduce it with a simple project then that would be a big help.

ldesroziers commented 11 years ago

Gonna try :-)

ldesroziers commented 11 years ago

God dammit, you were right ! I tried to reproduce it on a new project.. First, there were no bug because I instanciated the blurView with a clearly defined frame. And then I tried to instanciate it with CGRectZero, and boom! And forget what I said about the continuous logs while scrolling: logs only appear once.

nicklockwood commented 11 years ago

I've fixed this in 1.3.3.

ldesroziers commented 11 years ago

Nick, I'm still having an issue with zero-sized blurView. In fact, your test seems to only 'work' if both width & height are empty. In my case, the height is never empty (because it's a navbar-like and the height is a static value), but the width depends of the superview (the rootViewController's view of my window), and unfortunately it's 0 when I start my app.

nicklockwood commented 11 years ago

oh, that's odd. OK, I'll try again.

nicklockwood commented 11 years ago

The documentation for CGRectIsEmpty says that it should return YES if the width OR height are zero. Is it possible that something else is going wrong?

ldesroziers commented 11 years ago

Well, I tried to put a MAX() for the width like that: CGRect filtersViewFrame = CGRectMake(0, 0, MAX(CGRectGetWidth([[self view] bounds]),1), [[self filtersView] sizeThatFits:CGSizeZero].height);

And I no longer get warnings. Putting back CGRectGetWidth([[self view] bounds]) brings up warnings again. :/

nicklockwood commented 11 years ago

OK, I can't reproduce this in 1.4. If you're still seeing it, please send me a sample project.

ldesroziers commented 11 years ago

It's OK:) Thank you very much!

jhollida24 commented 10 years ago

I'm still seeing this error:

thread #1: tid = 0xe049, 0x000000018506be28 CoreGraphics`CGPostError, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1
frame #0: 0x000000018506be28 CoreGraphics`CGPostError
frame #1: 0x000000018506be1c CoreGraphics`handle_invalid_context + 28
frame #2: 0x0000000187b9a8d8 QuartzCore`-[CALayer renderInContext:] + 380
frame #3: 0x0000000100479848 Brainscape`-[FXBlurView snapshotOfUnderlyingView](self=0x00000001781e1000, _cmd=0x00000001005b0bf8) + 1584 at FXBlurView.m:468
frame #4: 0x000000010047a090 Brainscape`-[FXBlurView updateAsynchronously:completion:](self=0x00000001781e1000, _cmd=0x00000001005b0a0a, async=true, completion=0x000000016fd6c2e8) + 104 at FXBlurView.m:525
frame #5: 0x0000000100477c48 Brainscape`-[FXBlurScheduler updateAsynchronously](self=0x0000000170255630, _cmd=0x00000001005b0961) + 1404 at FXBlurView.m:232
frame #6: 0x0000000100477544 Brainscape`-[FXBlurScheduler addView:](self=0x0000000170255630, _cmd=0x0000000188f92d16, view=0x00000001781e1000) + 244 at FXBlurView.m:198
frame #7: 0x0000000100478ebc Brainscape`-[FXBlurView schedule](self=0x00000001781e1000, _cmd=0x00000001895e21e6) + 252 at FXBlurView.m:400
frame #8: 0x0000000100478db4 Brainscape`-[FXBlurView didMoveToWindow](self=0x00000001781e1000, _cmd=0x0000000188630136) + 92 at FXBlurView.m:393
isair commented 10 years ago

This error happens to me on orientation change and causes my app to crash. I have an FXBlurView inside a UITableViewCell.