SWRevealViewController icon indicating copy to clipboard operation
SWRevealViewController copied to clipboard

Black screen appears sometimes

Open Crocotronic opened this issue 9 years ago • 66 comments

Hello, It seems that I'm the only one having issues like this? As the title already says I sometimes get a black screen on my iPhone 5 (iOS 7). Mostly at startup when panning from left to right. I set bounceBackOnOverdraw and bounceBackOnLeftOverdraw to false and a rearViewRevealDisplacement of 100. I also download some data from the internet at startup, but I think there shouldn't be performance problems. Do you have any experiences with this issue?

Best regards Benny

Crocotronic avatar Aug 31 '14 13:08 Crocotronic

I'm having the same issue, black screen appears then disappears quickly

SalehAlbuga avatar Sep 08 '14 10:09 SalehAlbuga

'm having the same issue too, but I do not know how to fix it

balkarov avatar Sep 11 '14 17:09 balkarov

Yeah, +1 this. I see it too and would like to understand how to get it cleared up. I see it when the device is in landscape mode. I run with two RevealControllers. I can reproduce it every time when I am swiping the child most front view controller to the left. I will see a black bar on the right side for just a moment. Cannot fully tell how wide it is.

brianhmayo avatar Sep 14 '14 02:09 brianhmayo

I went back to using version 2.2 (with Cocoapods) and it solved the black screen problem for me.

TiagoLira avatar Sep 15 '14 17:09 TiagoLira

This seems to be a recurrent issue, but I can't reproduce it and I never saw it. Please, can someone post an example -ideally derived from one the existing ones- so I can reproduce it? You are all providing very little information on the particular conditions or code that produces this. Thanks.

John-Lluch avatar Sep 15 '14 20:09 John-Lluch

It appears randomly, I'm finding a way to reproduce it. But when it appears I get a long log with "<Error>: CGContextRestoreGState: invalid context 0x0 his 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." errors

SalehAlbuga avatar Sep 15 '14 20:09 SalehAlbuga

Ok, but how is this related with the SWRevealViewController?. The class does not use CGContexts as it is not drawing anything.

John-Lluch avatar Sep 15 '14 20:09 John-Lluch

It only happens when I slide the left menu the becomes black & then normal again & I get that in the log. The app I'm making doesn't draw anything either

SalehAlbuga avatar Sep 15 '14 20:09 SalehAlbuga

I am just trying to guess what could produce this, but so far I am lost because as said I can't reproduce it.

Does setting toggleAnimationType to SWRevealToggleAnimationTypeEaseOut or to SWRevealToggleAnimationTypeSpring make any difference?

Also, please can you try to replace this

    if ( fromViewController )
    {
        [UIView transitionFromView: 

by this

    if ( YES ||  fromViewController )
    {
        [UIView transitionFromView:

in

- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext

to see if that makes any change?

Thanks.

John-Lluch avatar Sep 16 '14 07:09 John-Lluch

Hi, I have this issue as well.

It happens only with Spring animation and specific duration time. In my case with duration = 0.061204 it is reproducible 100% of time.

Might be an iOS bug. Hope it will help you with fixing it.

wizdaz2 avatar Sep 18 '14 03:09 wizdaz2

have seen it many times, when the frontView has heavy graphics content. In previous version of swrevealcontroller, problem didn't existed

ilant avatar Sep 29 '14 13:09 ilant

same problem here...

savetree avatar Oct 10 '14 19:10 savetree

Yep also happens for me. Very intermittent. Haven't been able to identify a way to reproduce it on demand.

paulsturgess avatar Oct 13 '14 20:10 paulsturgess

Also can confirm I am getting the black screen on 2.3.0. It happens literally randomly and I can't seem to reproduce it at all.

micnguyen avatar Nov 04 '14 06:11 micnguyen

I have the same problem. I can't figure out what triggers it. I've tried reverting to 2.2.0 but it happens with that version also. It's really odd - I can run my app 10 times and not see it, and then the next time I'll see it, just once and not again for that session. Will keep trying to see if I can get something reproducible.

mervinlabs avatar Nov 19 '14 00:11 mervinlabs

I have this error when importing SWRevealViewController 1 in iOS 8 says that method 'target transform' in protocol 'UiViewControllerContextTransitioning' not implemented do anyone know how to solve it I tried but no luck

PerfectAchiever avatar Nov 19 '14 02:11 PerfectAchiever

Confirmed I'm seeing this issue as well. Will also hunt for repro steps.

carloperez avatar Nov 21 '14 06:11 carloperez

Do you think if isubmit the app to itunes for approval will they disapprove the app as of this error the app works fine

PerfectAchiever avatar Nov 21 '14 06:11 PerfectAchiever

So I made the change to

if ( YES || fromViewController ) { [UIView transitionFromView:

Initially it seemed like this helped but once I got to playing in the app long enough the issue happened again.

I then set the toggle type to SWRevealToggleAnimationTypeSpring and currently I am not seeing the problem.

Will report back again after a day of this. Is anyone else seeing a difference with the above changes?

carloperez avatar Nov 21 '14 06:11 carloperez

Can you explain more

PerfectAchiever avatar Nov 21 '14 06:11 PerfectAchiever

Do a search for that line in your project - you'll find it in the SWRevealController code - and then replace the code.

For the flag, just set it the same way you set other properties when you create an instance of SWRevealController.

carloperez avatar Nov 21 '14 15:11 carloperez

Hi i'm new in iOS programming and i'm struggling doing this could you give me more hints will be appreciate it so much

PerfectAchiever avatar Nov 21 '14 18:11 PerfectAchiever

I am getting that black screen randomly every 30/40 slides (sometimes less frequently, sometimes more frequently). @John-Lluch as my app is in early stage, can I send it to you over an email so you can take a look at it? /only your library has been added + few other controllers to test the whole logic/

grabbou avatar Jan 07 '15 21:01 grabbou

For me, this happens to me when making FrontView come out from the left(out of the screen, on the left side) to the right like a pop-out menu.

Created my own FrontView VC then implemented UIView in there, positioned the view on the left then when either touched the button or swiped, it comes out to the right(over RearView).

All works well except RearView stays black. Another thing is that when my FrontView is still out of the sight(on the left), interaction on RearView doesn't work but instead when FrontView is out(over RearView), RearView's interaction works ON FrontView having FrontView on it so I'm guessing even though I've implemented and re-positioned my own FrontView, the original FrontView's still there. I just don't know how to move it as my own FrontView moves or sync them.

Help?! captura de pantalla 2015-01-12 a las 14 51 49

holahyunsik avatar Jan 12 '15 06:01 holahyunsik

I've also notice this problem with black screen appearing randomly. I noticed it on both iPhone 5 iOS 8.1 simulator and iPhone 5 iOS 8.1 device. It appears that this problem exists only when I use built in panGesture and I slide my finger quite fast to show the menu.

leszek-s avatar Jan 19 '15 18:01 leszek-s

@carloperez did your solution fix the problem in the end?

What change did you make to the if ( YES || fromViewController )

paulsturgess avatar Jan 28 '15 12:01 paulsturgess

Hi all,

Have you tried to set 'toggleAnimationType' to SWRevealToggleAnimationTypeEaseOut ?. I think this is an Apple bug when using spring animations.

Thanks

John-Lluch avatar Jan 28 '15 14:01 John-Lluch

This bug exists in v2.3.0 and also in v2.2.0 however it looks like it does not exist in v2.1.0. I've switched to v2.1.0 few days ago and since that day I haven't seen the black screen and everything works as expected. For everyone who is experiencing this problem I can recommend switching back to v2.1.0.

leszek-s avatar Jan 28 '15 15:01 leszek-s

Hi @paulsturgess: No, that didn't do the trick for me. There's a post from @John-Lluch on September 16th that describes it. I had actually thought I might just forego the 'tray' effect and head for more traditional pastures but it seems there's more interest in finding a fix here now. Unfortunately I've got no new data. : /

@John-Lluch I had changed the toggleAnimationType to Spring before as instructed and I can verify the bug still showed. I will try with EaseOut today.

@fins Just wondering how reliably were you triggering the bug in 2.3.0 and 2.2.0? Sometimes I wouldn't trigger it in a day so I would think it was gone.

carloperez avatar Jan 28 '15 15:01 carloperez

@carloperez in v2.3.0 and v2.2.0 I was able to reproduce this bug every time I runned the app in 20-40 attempts (pan gestures). Since I switched to 2.1.0 few days ago I was not able to reproduce it doing the same pan gesture test and I've tried a lot so it seems that it is working fine in this version.

leszek-s avatar Jan 28 '15 15:01 leszek-s

I've just downloaded https://github.com/John-Lluch/SWRevealViewController/archive/v2.3.0.zip and I was able to reproduce black screen bug on example project RevealControllerExample on iPhone 5 (8.1) simulator few times and I've recorded a video with it. Black screen is visible at 1:17 here: https://www.youtube.com/watch?v=kiDCeQLyRqk I hope this will help finding the problem.

leszek-s avatar Jan 28 '15 17:01 leszek-s

@John-Lluch switching to SWRevealToggleAnimationTypeEaseOut seems to have fixed it for me. Thanks!

schayes04 avatar Jan 28 '15 18:01 schayes04

Thanks for all the info, @fins. @John-Lluch from the notes the 2.3 notes state:

"This version fixes an old bug that caused an incorrect initialization of the class on particular scenarios. The old RevealControllerStoryboardExample has been removed from the repo as it was deprecated, please use the newest RevealControllerStoryboardExample2 instead."

Could you comment a bit more on the frequency/severity of this bug? I'd like to keep the spring animation and will downgrade to 2.1.0 depending on the dangers...

carloperez avatar Jan 29 '15 16:01 carloperez

I downgraded to 2.1.0 too and everything works perfect except the "swipe to delete" function of the UITableViewController

Crocotronic avatar Feb 08 '15 15:02 Crocotronic

@schayes04 will try and let you know if it works for me as well. Black screen does not appear when pan gesture is disabled. By tapping on the icons and opening up drawers programatically, I can't make the black screen flash appear.

grabbou avatar Feb 11 '15 00:02 grabbou

SWRevealToggleAnimationTypeEaseOut also fixed it for me, so whether it is a Apple bug or the code in sw itself, hoping we can find a workaround. I would rather the spring animation myself.

gintechsystems avatar Feb 13 '15 11:02 gintechsystems

My configuration: XCode 6.1.1 iOS SDK 8.1 Deployment target 8.1 Test device: iPhone 5 iOS: 8.1.3

Hello guys, I tried by setting toggle type to SWRevealToggleAnimationTypeEaseOut, but sadly enough this doesn't work for me. SWRevealViewController works when I made a simple test app to test whether it's working or not. But when I wanted to include it into my real app I get a black screen as my rear view. In my case sw_front connects to a UITabBarController object. I'll try an older version, but it would be great if this bug get fixed, it's really a nice must-have project.

Note: What's weird in my situation, I also see an empty tabbar on the bottom of the black screen. I haven't studied the source code of SWRevealViewController well, but I can imagine it doesn't work well with a Navigation Controller or a TabBar Controller.

bouchtaoui-dev avatar Feb 19 '15 11:02 bouchtaoui-dev

I have tried testing it again and it still seems to be working for me, with the latest release of iOS and SWRevealViewController. I do not use the tabBar controller though, only the navigation controller with paging. I would try an older project unless you really need to stay with the new one, do you also see the black screen when trying to use spring?

gintechsystems avatar Feb 20 '15 02:02 gintechsystems

@gintechsystems it just doesn't work. I replaced TabBar controller with a ViewController that holds a pageviewcontroller, with no result.

What do you mean by "spring"? Anyway I've set SWRevealToggleAnimationTypeEaseOut in the SWRevealViewController, I've set it when initializing the gesture action in my ViewController, all with no result. I don't think it has to do with XCode or iOS version. Because I've tested again with just one simple ViewController as the front view and a Viewcontroller as the rear view and it worked. I just can't think of any logic assumption what 's going on here.

bouchtaoui-dev avatar Feb 20 '15 13:02 bouchtaoui-dev

I mean the SWRevealToggleAnimationTypeSpring option instead of EaseOut. Nah, I doubt it is the Xcode, but possibly iOS or the latest release of SWRevealViewController. So it works without a tabBar?

gintechsystems avatar Feb 20 '15 18:02 gintechsystems

It does not work with or without a tab bar. I do not have a tab bar in my application but I do have a navigation controller. In my case latest version v2.3.0 and v2.2.0 was not working. I was getting black screen quite often. Now it is about one month since I switched to v2.1.0 and since that time I did not see the black screen. Everything works properly with v2.1.0.

leszek-s avatar Feb 20 '15 18:02 leszek-s

I might have to check out v2.1.0, as the recent changes do not affect me. Are you saying it does not work WITH or WITHOUT the tab bar, your first sentence kinda does not make sense.

gintechsystems avatar Feb 20 '15 18:02 gintechsystems

I meant that it does not work with a tab bar and it does not work without a tab bar. It does not matter if you are using a tab bar or not. Newest version 2.3.0 just does not work properly.

leszek-s avatar Feb 20 '15 18:02 leszek-s

I disagree, I do not have a tab bar in 2.3.0 and it works perfect, all I have is navigation controller. The only issue I have is I cannot use the spring animation.

gintechsystems avatar Feb 20 '15 18:02 gintechsystems

In my "big" project I changed SWRevealViewController to 2.1.0 and even set it as the initial view controller and added two dummy view controllers (one for the side menu and one for the content) just to test it. Even than I get the black screen with in the bottom a gray bar. So I just gave up, it could be the target version, the build compiler or whatever. Anyway, thnx.

bouchtaoui-dev avatar Feb 24 '15 09:02 bouchtaoui-dev

You should upload your example project, I (or someone in this thread) can check it out and see if we notice any issues. Just a suggestion. Otherwise, good luck with it :)

gintechsystems avatar Feb 24 '15 09:02 gintechsystems

@gintechsystems thnx for your offer to help me, I really appreciate it. Because of lack of time, I searched an alternative solution and I came across RESideMenu that works for me. But I like SWReveal more because of the simplicity. I hope to have some time free to create an example project where the black screen problem occurs and share it with you to analyze the problem. Thank you.

bouchtaoui-dev avatar Feb 24 '15 15:02 bouchtaoui-dev

Had the same issue. Setting revealAnimationType = SWRevealToggleAnimationTypeEaseOut fixes it but I liked SWRevealToggleAnimationTypeSpring better.

emitelma avatar May 17 '15 12:05 emitelma

Hey guys, I'm setting rearViewRevealWidth = 305. The following code patch can ALWAYS reproduce it. I'm not familiar with animation. Hope @John-Lluch or somebody can find a solution soon!

--- a/Pods/SWRevealViewController/SWRevealViewController/SWRevealViewController.m
+++ b/Pods/SWRevealViewController/SWRevealViewController/SWRevealViewController.m
@@ -1412,7 +1412,8 @@ const int FrontViewPositionNone = 0xff;
         }
         else
         {
-            [UIView animateWithDuration:_toggleAnimationDuration delay:0.0 usingSpringWithDamping:_springDampingRatio initialSpringVelocity:1/duration
+            CGFloat blackScreenVelocity = 16.5;
+            [UIView animateWithDuration:_toggleAnimationDuration delay:0.0 usingSpringWithDamping:_springDampingRatio initialSpringVelocity:blackScreenVelocity
             options:0 animations:animations completion:completion];
         }
     }

Set blackScreenVelocity between 16.3 and 16.7, with default _toggleAnimationDuration = 0.3 can reproduce this issue.

yzlai avatar May 31 '15 14:05 yzlai

It seems still an same problem.xcode version:Version 6.4 (6E35b),iOS:8.4.1

ohcrider avatar Aug 25 '15 05:08 ohcrider

I think this is a nasty bug that can't be easily fixed.

bouchtaoui-dev avatar Sep 01 '15 09:09 bouchtaoui-dev

Yeah probably, I am just not using the spring animation.

gintechsystems avatar Sep 01 '15 14:09 gintechsystems

not using the spring animation is not this problem

ohcrider avatar Sep 04 '15 09:09 ohcrider

For me that is the only time I have the issue though...I know it is not the spring animation itself that is the issue. I will probably take a look at this again myself sometime if no one else gets to it. I would prefer the spring animation over the others choices.

gintechsystems avatar Sep 04 '15 14:09 gintechsystems

I am getting random black screen in the app. Is the general consensus is to set toggleAnimationType to SWRevealToggleAnimationTypeEaseOut ?

Any other suggestions for root cause ?

Thanks, Marik

mmarshak avatar Nov 03 '15 06:11 mmarshak

I still have the issue and I have tried setting toggleAnimationType to SWRevealToggleAnimationTypeEaseOut but it didn't work. Any other suggestion? thanks

jramgit avatar Nov 11 '15 07:11 jramgit

I had the same experience with the black gap when I using gesture pan.

I found it out the reason was the rearpageviewcontroller is not initialized together with frontviewcontroller. And when I am using gesture, the animation is started BEFORE the rear view controller actually loaded.

my solution is I created my own class which inherited from the swrealcontroller class and I initialize the rearviewcontroller right after the front view controller initialized.

jovirus avatar Jul 04 '16 11:07 jovirus

Can you see this sample?

SWPanGesture.zip

iDevelopper avatar Jul 04 '16 11:07 iDevelopper

It looks fine, I have a lot of logic before the rear page view appears, I think it creates the problem too.

jovirus avatar Jul 04 '16 12:07 jovirus

@jovirus are you saying you have a solution?

gintechsystems avatar Jul 04 '16 16:07 gintechsystems

A solution for what?

iDevelopper avatar Jul 04 '16 18:07 iDevelopper

@gintechsystems you can try iDeveloper's example, it works fine.

jovirus avatar Jul 05 '16 10:07 jovirus

@jovirus thanks

gintechsystems avatar Jul 05 '16 12:07 gintechsystems

The issue is back guys...

takasurazeem avatar Apr 18 '18 12:04 takasurazeem

I recommend to use another Menu library. There's plenty of them, so...

bouchtaoui-dev avatar Apr 18 '18 13:04 bouchtaoui-dev

Yes, for example:

https://github.com/iDevelopper/PBRevealViewController

It's the most similar library, inspired by SW! Thanks to @John-Lluch

iDevelopper avatar Apr 18 '18 16:04 iDevelopper