kelan / yrkspinningprogressindicator Goto Github PK
View Code? Open in Web Editor NEWA resizable, recolorable clone of the spinning NSProgressIndicator.
License: BSD 3-Clause "New" or "Revised" License
A resizable, recolorable clone of the spinning NSProgressIndicator.
License: BSD 3-Clause "New" or "Revised" License
I wanted to use this but then discovered that animation is done using a timer... it'd be really cool to use CVDisplayLink instead. Should be much more reliable for smooth animations.
Hello,
I noticed the default setting _usesThreadAnimation=YES, uses a separate Thread to update the spinners animation. While doing that it makes a non-thread safe calls in:
-(void) updateFrame
...
if (_usesThreadedAnimation) {
// draw now instead of waiting for setNeedsDisplay (that's the whole reason
// we're animating from background thread)
[self display];
}
as well as
-(void)actuallyStopAnimation
...
if (!_displayedWhenStopped)
[self setHidden:YES];
... and ....
[self setNeedsDisplay:YES];
Most of the time this is not a problem, but given enough time/calls, this will eventually lead to a NSInternalInconsistencyException and a program crash.
The workaround is to set _usesThreadedAnimation to NO. A better solution would be to que the non-tread safe calls to the main-loop.
I had to dig through the class code to determine who "sender" was supposed to be when calling -startAnimation:
.
Hi,
FYI: I made a fork, cleaned a few things up, pulled falkobuttler's ARC changes in #2, and submitted this as a cocoapod. I may continue to add more to this - plan on using it in a project.
Doesn't look like you're maintaining this anymore, but if you are, certainly feel free to claim the pod: https://trunk.cocoapods.org/claims/new
Cheers,
Nathan
I just search a bit forward to understand what was crashing, and finally this crash was due to a division by 0. In fact, any variables are getting their default value because the initWithFrame:
is not called while initialised from a storyboard.
I think a workaround with the awakeFromNib
coud work, I will check it out if I have time later.
�[31m*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'appendBezierPathWithArcWithCenter:radius:startAngle:endAngle:clockwise:: illegal angle argument'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff90e7303c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff8f25876e objc_exception_throw + 43
2 CoreFoundation 0x00007fff90e72eed +[NSException raise:format:] + 205
3 AppKit 0x00007fff8cd7a7b7 -[NSBezierPath appendBezierPathWithArcWithCenter:radius:startAngle:endAngle:clockwise:] + 135
4 KaraFun 0x000000010028f44a -[YRKSpinningProgressIndicator drawRect:] + 2474
5 AppKit 0x00007fff8cc5d749 -[NSView(NSInternal) _recursive:displayRectIgnoringOpacity:inGraphicsContext:CGContext:topView:shouldChangeFontReferenceColor:] + 1186
6 AppKit 0x00007fff8cc5d168 __46-[NSView(NSLayerKitGlue) drawLayer:inContext:]_block_invoke + 218
7 AppKit 0x00007fff8cc5ce11 -[NSView(NSLayerKitGlue) _drawViewBackingLayer:inContext:drawingHandler:] + 2407
8 AppKit 0x00007fff8cc5c493 -[NSView(NSLayerKitGlue) drawLayer:inContext:] + 108
9 QuartzCore 0x00007fff88a843c7 CABackingStoreUpdate_ + 3306
10 QuartzCore 0x00007fff88a836d7 ___ZN2CA5Layer8display_Ev_block_invoke + 59
11 QuartzCore 0x00007fff88a83694 x_blame_allocations + 81
12 QuartzCore 0x00007fff88a7743c _ZN2CA5Layer8display_Ev + 1546
13 AppKit 0x00007fff8cbc842b _NSBackingLayerDisplay + 617
14 AppKit 0x00007fff8cbc5026 -[_NSViewBackingLayer display] + 834
15 QuartzCore 0x00007fff88a757fd _ZN2CA5Layer17display_if_neededEPNS_11TransactionE + 603
16 QuartzCore 0x00007fff88a74e81 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 35
17 QuartzCore 0x00007fff88a74612 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
18 QuartzCore 0x00007fff88a743ae _ZN2CA11Transaction6commitEv + 390
19 AppKit 0x00007fff8cc4dc58 -[NSView(NSLayerKitGlue) _drawRectAsLayerTree:] + 517
20 AppKit 0x00007fff8cc47788 -[NSView _drawRect:clip:] + 397
21 AppKit 0x00007fff8cc46cfa -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 1875
22 AppKit 0x00007fff8cc44b96 -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 913
23 AppKit 0x00007fff8cc442f3 -[NSThemeFrame _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 333
24 AppKit 0x00007fff8cc4068b -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 2761
25 AppKit 0x00007fff8cbf81ae -[NSView displayIfNeeded] + 1876
26 AppKit 0x00007fff8cbf7a09 -[NSWindow displayIfNeeded] + 236
27 AppKit 0x00007fff8cc9a4a2 -[NSWindow _reallyDoOrderWindow:relativeTo:findKey:forCounter:force:isModal:] + 1991
28 AppKit 0x00007fff8cc99787 -[NSWindow _doOrderWindow:relativeTo:findKey:forCounter:force:isModal:] + 829
29 AppKit 0x00007fff8cc993db -[NSWindow orderWindow:relativeTo:] + 159
30 AppKit 0x00007fff8cc909a2 -[NSWindow makeKeyAndOrderFront:] + 47
31 KaraFun 0x000000010009dd2f -[KFAppDelegate_OSX launchBeforeAuthentification] + 799
32 KaraFun 0x000000010009d4c0 -[KFAppDelegate_OSX launchApp] + 352
33 KaraFun 0x000000010009d00d __51-[KFAppDelegate_OSX applicationDidFinishLaunching:]_block_invoke + 1149
34 libdispatch.dylib 0x00000001009abd43 _dispatch_client_callout + 8
35 libdispatch.dylib 0x00000001009abd2e dispatch_once_f + 525
36 KaraFun 0x000000010009cb50 -[KFAppDelegate_OSX applicationDidFinishLaunching:] + 192
37 CoreFoundation 0x00007fff90e2f45c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
38 CoreFoundation 0x00007fff90d1f634 _CFXNotificationPost + 3140
39 Foundation 0x00007fff86dbb9d1 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
40 AppKit 0x00007fff8cbfea8b -[NSApplication _postDidFinishNotification] + 291
41 AppKit 0x00007fff8cbfe7f6 -[NSApplication _sendFinishLaunchingNotification] + 191
42 AppKit 0x00007fff8cbfb946 -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:] + 574
43 AppKit 0x00007fff8cbfb385 -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 244
44 Foundation 0x00007fff86dee748 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 290
45 Foundation 0x00007fff86dee5b9 _NSAppleEventManagerGenericHandler + 102
46 AE 0x00007fff8b54334c _Z20aeDispatchAppleEventPK6AEDescPS_jPh + 531
47 AE 0x00007fff8b5430c9 _ZL25dispatchEventAndSendReplyPK6AEDescPS_ + 31
48 AE 0x00007fff8b542fd3 aeProcessAppleEvent + 295
49 HIToolbox 0x00007fff85eb9c6e AEProcessAppleEvent + 56
50 AppKit 0x00007fff8cbf4da2 _DPSNextEvent + 2249
51 AppKit 0x00007fff8cbf3e58 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 346
52 AppKit 0x00007fff8cbe9af3 -[NSApplication run] + 594
53 AppKit 0x00007fff8cb66244 NSApplicationMain + 1832
54 KaraFun 0x000000010011cad2 main + 34
55 libdyld.dylib 0x00007fff8628a5c9 start + 1
56 ??? 0x0000000000000003 0x0 + 3
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Tried not drawing a background, but it's still showing the 4 corners as white. Any ideas on how to fix? thx!
Please consider using this approach
https://github.com/JanX2/yrk-spinning-progress-indicator-layer/tree/idiomatic-core-animation
instead of using displaylink
https://github.com/kelan/YRKSpinningProgressIndicator/compare/displaylink
This way, everything runs in the background using the GPU where possible. Using CoreAnimation directly is much more efficient. It’s also easier to maintain.
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.