kconner / kmcgeigercounter Goto Github PK
View Code? Open in Web Editor NEWA framerate meter that clicks like a Geiger counter when your animation drops a frame
License: MIT License
A framerate meter that clicks like a Geiger counter when your animation drops a frame
License: MIT License
https://github.com/Carthage/Carthage
This would require building as a framework.
The KMCGeigerCounter is enabled on the top center of the main screen, however it's the safe area of iPhone X.
I've fixed some bugs in the iOS 9
branch:
Thanks for writing in about those. But I'm not able to ship a new release of the pod yet, because I haven't solved the most serious problem, which has to do with my method of measuring the timing of drawing.
// Low framerates can be caused by CPU activity on the main thread or by long compositing time in (I suppose)
// the graphics driver. If compositing time is the problem, and it doesn't require a lot of main thread activity
// between frames, then the framerate can drop without CADisplayLink detecting it.
// Therefore, put an empty 1pt x 1pt SKView in the window. It shouldn't interfere with the framerate, but
// should cause the CADisplayLink callbacks to match the timing of drawing.
// TODO: This should be lightweight but affects the framerate on iOS 9, particularly in the example application.
// Maybe if I use only the SKView and not the CADisplayLink?
// No, that doesn't help. The SKView alone is causing the drawing latency. The CADisplayLink does not interfere.
// SceneKit doens't exist before iOS 8, so I'd prefer not to rely on it.
// A GLKViewController works on the default run loop, so it doesn't get updates during core animation scrolling.
// Using a custom view with -drawRect: or -displayLayer:, callbacks happen just as often as CADisplayLink.
// I need a new way to accurately detect when a frame is drawn to the screen without affecting the framerate.
I've tried several things, but I don't have a solution yet. If you want to see where I am on this, check out the ios9
branch. To see the problem for yourself, try running the example application on your device with and without this line in -[KMCGeigerCounter start]
:
[[UIApplication sharedApplication].keyWindow addSubview:self.sceneView];
You'll notice that without the line, the framerate on scrolling the first tab is not smooth, but the meter reads 60. This is because the cost of rendering that view is not on the main thread like layout. With that line included, I'm able to detect the delays, but the framerate actually gets worse and should not.
this is how i use:
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[[[UIApplication sharedApplication] delegate] setWindow:_window];
// main view controller
homeViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateInitialViewController];
[homeViewController setDelegate:self];
UINavigationController* navView = [[DirectionUINavigationController alloc] initWithRootViewController:homeViewController];
[_window setRootViewController:navView];
[_window makeKeyAndVisible];
#ifndef APP_STORE_RELEASE
[KMCGeigerCounter sharedGeigerCounter].enabled = YES;
#endif
error info:
*** Assertion failure in -[UIApplication _runWithMainScene:transitionContext:completion:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3505.16/UIApplication.m:3294
remove KMCGeigerCounter app ok.
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Application windows are expected to have a root view controller at the end of application launch'
Installation instructions need to be say that you have to add SpriteKit to "Build Phases - Link Binary With Libraries" for users not using Cocoapods.
Using this pod on a device with iOS 9.3.2 I get a crash because UIKit complains that every window needs to have a rootViewController set after application:didFinishLaunchingWithOptions:
.
This happens because the KMCGeigerCounter creates its own window but doesn't set a rootViewController there. So the fix is to just set some UIViewController on it:
[self.window setRootViewController:[UIViewController new]];
Would be nice if you could please make this small change and push out a new release to CocoaPods. 😉
When compiling with the iOS 8.1SDK in a Swift & Objective-C++ project, I get the build error above on line 18 of KMCGeigerCounter.m
Apparently static NSInteger const is not "good enough" for array sizes? http://stackoverflow.com/questions/3988122/static-const-int-not-good-enough-for-array-size
Anyone else encounter this issue? How did you work around it, besides just using #define or hardcoding the value 60?
2017-08-26 18:35:17.370 KMCGeigerCounter[71863:6870637] *** Assertion failure in -[UIApplication _runWithMainScene:transitionContext:completion:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.7.47/UIApplication.m:3677
2017-08-26 18:35:17.432 KMCGeigerCounter[71863:6870637] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Application windows are expected to have a root view controller at the end of application launch'
*** First throw call stack:
(
0 CoreFoundation 0x000000010a365b0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00000001098c2141 objc_exception_throw + 48
2 CoreFoundation 0x000000010a369cf2 +[NSException raise:format:arguments:] + 98
3 Foundation 0x000000010945c536 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 UIKit 0x000000010b2f6c46 -[UIApplication _runWithMainScene:transitionContext:completion:] + 3343
5 UIKit 0x000000010b2f37f3 -[UIApplication workspaceDidEndTransaction:] + 182
6 FrontBoardServices 0x000000010e3bd5f6 FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 24
7 FrontBoardServices 0x000000010e3bd46d -[FBSSerialQueue _performNext] + 186
8 FrontBoardServices 0x000000010e3bd7f6 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
9 CoreFoundation 0x000000010a30bc01 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
10 CoreFoundation 0x000000010a2f10cf __CFRunLoopDoSources0 + 527
11 CoreFoundation 0x000000010a2f05ff __CFRunLoopRun + 911
12 CoreFoundation 0x000000010a2f0016 CFRunLoopRunSpecific + 406
13 UIKit 0x000000010b2f208f -[UIApplication _run] + 468
14 UIKit 0x000000010b2f8134 UIApplicationMain + 159
15 KMCGeigerCounter 0x00000001092e47af main + 111
16 libdyld.dylib 0x000000010dd3e65d start + 1
17 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
not sure whether this project is still been updated.
in xcode9, ios10, i am testing my off-screen render demo, found that KCCounter show 60FPS while instrument show 30FPS
When you have Warnings set to be treated as Errors in Xcode the following prevent the app from building:
KMCGeigerCounter.m:198:74: Implicit conversion loses floating-point precision: 'double' to 'CGFloat' (aka 'float')
KMCGeigerCounter.m:237:47: Implicit conversion loses floating-point precision: 'double' to 'UIWindowLevel' (aka 'float')
Always crash like this "Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Application windows are expected to have a root view controller at the end of application launch'"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.