I have a game that runs fine as is (around 30fps), but fps went down the drain when I tried to implement ads. I tried Greystripe and iAds but with same result (iAds were maybe bit worse). Average fps is almost same, but there are huge spikes all the times (1-2 spikes per second) and game is unplayable.
I guess it is because ad is in another view. I read somewhere that opengl apps on iphone don't like having another views with them, but there is plenty of games with ads on app store. How do they do it?
My implementation should be ok. I did everything as documentation and samples told me. I have my opengl view and ad view as subviews in app window, adview being in front of opengl view and thus covering part of it. Could this be the problem? Is it better to make opengl view smaller to left space for ad so they don't overlap? Do you have any other ideas what could be wrong?
Lope, I've created a gist at this link with a singleton "AdManager" class I wrote to handle iAds using cocos2d. Cocos2d sits on top of OpenGL, of course, and I've found that this code doesn't affect FPS even for relatively complicated games.
You'll have to modify this a bit to work with your application, changing out the cocos2d calls, etc, but this will give you asynchronous loading of iAds, which should help the FPS issue.
To use this class, include its header and call
[[AdManager sharedManager] attachAdToView:self.view];
wherever you need iAds. The ads will remain hidden until an ad loads, at which time they'll pop up at the top of screen. (The class works for iOS 4.0, 4.1 and 4.2).
Also, I should add that I have cocos2d running inside of an overall UIViewController that I call "Cocos2DController". When I attach the ads to a cocos2d view, I'm using
[[AdManager sharedManager] attachAdToView:[[CCDirector sharedDirector] openGLView]];
Best of luck!
We can hit and miss with apple's choices, but go for the sure thing and implement the ads in other parts to be appealing and not intrusive. It will be better for the framerate, and for you.
Try downloading the ads in a seperate, low priority, thread. You can, thus, nsure that the ads loading does not take too much CPU time. With a bit of CPU synchronisation you can make sure you don't try to display the new ad until it is completely ready to display. Sure it will suck some CPU time away from what you are trying to do but set your priorities right and it should only suck time when you are busy doing nothing.
Please excuse the thread necro'ing here, but I've used Stack Overflow a lot to help me through the problems I've had during coding, and thought my experience might be useful to someone in the future.
My simple cocos2d game ran with decent FPS (rarely changed the FPS display at all) until I implemented AdWhirl (integrating AdMob + iAd only). It would then run OK for the first few iterations, but upon upon the 9th or 10th scene refresh (single screen game, time in each scene < 5 seconds on average) the FPS would dive to ~20FPS, and drop again each time the scene refreshed.
Turns out, in my n00biness (this may be particular to me :) ), I was calling the scene from within itself. That is, once the actions had finished, the last action was to call the main scene again (a lazy way of rebuilding the scene for the user to have another go). This init'd the views and view controllers I had inserted to handle the AdWhirl ads all over again, and not only did I have a memory leak, I had 10+ view controllers all trying to request and service ads from AdWhirl. Once I got a clue and took that self-referring loop out, all was good.
Related
My problem is that my GameScene starts with about double the nodes and draws count and 40 fps for several seconds. This problem appears only on my iPad (mini retina) while on my iPhone (5) the game runs smoothly from the start although the nodes are still a lot more than what it should be
This 40fps problem is an issue within the iOS frameworks. It's created by some kind of throttling (by iOS).
Perhaps this throttling was designed to give a more consistent experience for an app struggling to maintain 60fps. But nobody knows.
Apple has never commented on it.
It became prevalent throughout the rollout of iOS 9 in Scene Kit, Sprite Kit and Metal. But has been seen within OpenGL ES locked projects, too.
However it was noticed in previous versions of iOS, too. Particularly within apps/games using CADisplayLink.
//Don't worry about those asking for code, you're right in your assumption that something is wrong that's not pertinent to your code.
Here's a deeper examination of a similar issue (probably from the same route cause) within Scene Kit: Inconsistent SceneKit framerate
Also got a problem with low FPS at the start (when using spritekit and uikit together )
I used xib with SKView and for me the solution was to add a dependency to the scene in the 'attribute inspector'
like at the picture below:
When my game starts the welcome screen has quite a few animations that play out. It was working fine until I implemented Unity Ads into my game. Now there is a noticeable lag when this bit of code executes:
Advertisement.Initialize ();.
It only lasts for a second but it is quite nasty. I tried putting the code in a co-routine and calling after the bulk of the heavy animations are completed but it still causes a considerable disruption to the remaining simple animations that are looping.
I'm thinking about putting it inside of my "Earn Button" onClick event but then the user will have to wait for the ads to load up which can take up to 5 seconds in my experience.
Is there a way I can call this code while the splash screen is loading?
I am testing on a Samsung S5 if that helps.
I think it takes long because it will download video Ads and try to cache them into the device. It will take even longer for devices with slow internet.
I assume you tried to use AsyncTask Here , if not, give it a go and Initialize UnityAds on a separate thread and see if it helps.
Another way is to call Initialize() and then check if the Video Ad is ready and put a loading screen while its downloading all the video Ads.
something like
While(! Advertisement.isready())
{
// loading..
}
I am not sure if it downloads videos every time you open the app or once every sometime, you need to ask UnityAds for that.
you get the idea.. hope this helps
I am working on an OpenGL application for the iPhone...
My app has only 2 views:
An OpenGL view and, as a subview for the OpenGL view, a view with the sole purpose of catching touch events...
The problem is that after about 10-15 minutes of keeping the app running on the device, I get a big (0.5s-1s) delay between every touchesMoved:withEvent: call
The animation runs smooth, and CPU usage is also not the problem (10% at most)
I have no idea what might be causing this
That is weird, eh.
This happens ON THE DEVICE right? When you are not running tethered from XCode?
I would guess you are using up a lot of memory, either a leak or just in some way using up more and more memory as time goes on.
Are you familiar with the various memory tools to watch what is going on?
Also, what about this: launch a few other large apps that remain in the background. Run your app until the problem exhibits. Then, kill the other apps. Does the problem suddenly go away? If so that would suggest you're low on memory.
Would be interested to hear.
I'm about to finish an app and now I wanted to add an animated splash screen with my company logo after the app finishes loading and launching. I can just use an animation with openGL for this, but I was wondering if it would be better to use a video..it's easier for me and the artist because he will only provide with an small video which i would reproduce after my app finish launching..less work.
I wonder if it's a good idea to do so...can I reproduce a small short video with the logo of my company or should i stick to making an animation ?
Also, reproducing video is memory intensive ?, because I'm loading some texture after my app finishes launching, and im wrried about that.
If i end up reproducing an small video, can i make it non interactive ? ( no pause, play stop, ect) so it looks like just as another animation to the eyes of the user ?
My other preocupation is quality...the quality of the video will look dramatically different to my animations in openGL ?
Thanks !
I can't tell you about the technical stuff, but what I can tell you is: don't use a splash screen. Directly from the Human Interface Guidelines:
Supply a launch image to improve user experience; avoid using it as an opportunity to provide:
• An “application entry experience,” such as a splash screen
...
Because users are likely to switch among applications frequently, you should make every effort to cut launch time to a minimum, and you should design a launch image that downplays the experience rather than drawing attention to it.
The HIG guidelines are intended (as far as I can tell) for Apps on the iPhone.
This is different from Games on the iPhone.
If your app provides some utility to the user, I agree completely with #Costique, #fabian789, and the HIG. The app should start instantly, with minimal loading and other distracting crap.
For a game, however, intros and the like are not only expected, but can also lead to a better user experience. My recommendation is to use a UIView Animation for only a small portion of the screen (the logo only). See Angry Birds as an example - their "animation" starts the same time the user's options do, so your animation (while quite pretty) doesn't block the user from using your app.
Disclaimer: the following is an entirely subjective humble user opinion. Please, don't take it to heart.
I hate video splash screens on my iPhone/iPad, however beautiful and stylish. What I like is apps which launch instantaneously. On iOS 4 chances are, I will see the startup animation once a month when the OS decides to terminate your app when the device is low on memory. So, now I tap the app icon and see the animation, now I tap it and don't (because it's already launched). It's inconsistent, out of your (and my) control, and ultimately makes little sense.
From both quality and aesthetics points of view, I think GL animation would better fit (hopefully) intense addictive action which follows. I'm not sure, however, that you will be able to load any resources in the background, while the animation plays, without making the animation stutter.
I've heard that OpenGL ES and standard iPhone UI controls don't play well together, but I'm wondering if anyone knows why, and what the effects are? I'm writing an OpenGL based game, and the view is loaded from a nib file with ui controls, and it seems to work ok, but the game is really simple at this point... does using ui controls cause some kind of performance hit?
UI events momentarily pause timers, like when scrolling a tableview. You can get around this by using the common runtime mode when creating a timer. It may slow down your rendering if you have a lot of layers because they all need to get redrawn every-time you refresh. So if your game runs at 60fps it will also redraw everything on top of the GLView, like UIImageViews, buttons etc. 60 times a second, which is a huge waste. It might not make a huge impact on your frame rate but it may make the device run hotter and drain the battery faster. Its best to draw your HUD using OpenGL, but it depends on the situation. For something that will be displayed only for a short time, like a menu I think you can get away with it.
Theres nothing wrong with it, its just wasteful.