We have crash in AVFoundation.
AVFoundation
+[AVOutputContext(FigRoutingContext) currentRoutingContextFactory]
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000a3c27beb8
Crashed: Thread
0 libobjc.A.dylib 0x183b8c910 objc_msgSend + 16
1 AVFoundation 0x18a5401bc +[AVOutputContext(FigRoutingContext) currentRoutingContextFactory] + 56
2 AVFoundation 0x18a53ae28 +[AVFigRoutingContextOutputContextImpl sharedAudioPresentationOutputContext] + 28
3 AVFoundation 0x18a4d0a24 +[AVOutputContext sharedAudioPresentationOutputContext] + 40
4 MediaPlayer 0x195deb1cc -[MPAVLightweightRoutingController pickedRoutes] + 68
5 MediaPlayer 0x195e04338 -[MPVolumeView _setShowsVolumeSlider:] + 96
6 MediaPlayer 0x195e02ad4 -[MPVolumeView layoutSubviews] + 208
7 UIKit 0x18e593770 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1420
8 QuartzCore 0x188b3525c -[CALayer layoutSublayers] + 184
9 QuartzCore 0x188b393ec CA::Layer::layout_if_needed(CA::Transaction*) + 324
10 QuartzCore 0x188aa5aa0 CA::Context::commit_transaction(CA::Transaction*) + 320
11 QuartzCore 0x188acd5d0 CA::Transaction::commit() + 580
12 QuartzCore 0x188acdd10 CA::Transaction::release_thread(void*) + 244
13 libsystem_pthread.dylib 0x1845e457c _pthread_tsd_cleanup + 572
14 libsystem_pthread.dylib 0x1845e42cc _pthread_exit + 88
15 libsystem_pthread.dylib 0x1845e40d4 _pthread_wqthread + 1472
16 libsystem_pthread.dylib 0x1845e3b08 start_wqthread + 4
The Crashlytics wrote:
This crash has non-main threads that appear to use UIKit classes or
functions. Generally speaking, it is only safe to use UIKit from the
main thread. Calling into UIKit from background threads can cause
unpredictable behavior (like crashes!). Please double check that all
of your code (that is not on the main thread) has been explicitly
marked as safe to use in the background by Apple.
But we don't use other threads in app.
Crashlytics logs:
Crashed: Thread 0 libobjc.A.dylib 0x184370910
objc_msgSend + 16 1 AVFoundation 0x18ad241bc
+[AVOutputContext(FigRoutingContext) currentRoutingContextFactory] + 56 2 AVFoundation 0x18ad1ee28
+[AVFigRoutingContextOutputContextImpl sharedAudioPresentationOutputContext] + 28 3 AVFoundation
0x18acb4a24 +[AVOutputContext sharedAudioPresentationOutputContext] +
40 4 MediaPlayer 0x1965cf1cc
-[MPAVLightweightRoutingController pickedRoutes] + 68 5 MediaPlayer 0x1965e8338 -[MPVolumeView _setShowsVolumeSlider:] + 96 6 MediaPlayer
0x1965e6ad4 -[MPVolumeView layoutSubviews] + 208 7 UIKit
0x18ed77770 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1420
8 QuartzCore 0x18931925c -[CALayer
layoutSublayers] + 184 9 QuartzCore 0x18931d3ec
CA::Layer::layout_if_needed(CA::Transaction*) + 324 10 QuartzCore
0x189289aa0 CA::Context::commit_transaction(CA::Transaction*) + 320 11
QuartzCore 0x1892b15d0 CA::Transaction::commit() +
580 12 QuartzCore 0x1892b1d10
CA::Transaction::release_thread(void*) + 244 13
libsystem_pthread.dylib 0x184dc857c _pthread_tsd_cleanup + 572
14 libsystem_pthread.dylib 0x184dc82cc _pthread_exit + 88 15
libsystem_pthread.dylib 0x184dc80d4 _pthread_wqthread + 1472 16
libsystem_pthread.dylib 0x184dc7b08 start_wqthread + 4
Init code:
self.volumeView = MPVolumeView.init(frame: CGRect.init(x: 0, y: 2,
width: 52.0,
height: 30.0))
self.volumeView?.showsVolumeSlider = false self.volumeView?.showsRouteButton = true
self.volumeView?.setRouteButtonImage(UIImage.init(named: "streaming_icon"), for: .normal)
self.volumeView?.setRouteButtonImage(UIImage.init(named: "selected_streaming_icon"), for: .selected)
self.volumeView.sizeToFit()
Please help resolve this issue.
I have contacted Apple and they have verified my theory that MPVolumeView performs UI layout changes on a background thread.
Bug report created.
Update 2018-05-30:
Engineering has determined that your bug report (40594280) is a duplicate of 39309134 and will be closed.
I have the same crash condition using MPVolumeView and AVPlayer.
With other weird things going on, like the volume slider disappearing.
The issues go away if I set the AVPlayer object attribute 'allowsExternalPlayback' to false.
player.allowsExternalPlayback = false
Seems strange but it worked.
Related
Does anynone know how to fix this issue? There are so many crashes posted to Fabric, which only appeared on iOS 11. Fabric gives a tip:
This crash has non-main threads that appear to use UIKit classes or functions. Generally speaking, it is only safe to use UIKit from the main thread. Calling into UIKit from background threads can cause unpredictable behavior (like crashes!). Please double check that all of your code (that is not on the main thread) has been explicitly marked as safe to use in the background by Apple.
Below is the crash session:
Crashed: WebThread
0 libobjc.A.dylib 0x1845041a0 objc_retain + 16
1 UIKit 0x18e850a10 -[UIView(Hierarchy) subviews] + 76
2 UIKit 0x18eb4416c -[UIView(CALayerDelegate) _wantsReapplicationOfAutoLayoutWithLayoutDirtyOnEntry:] + 72
3 UIKit 0x18e856e60 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1348
4 QuartzCore 0x1892e3948 -[CALayer layoutSublayers] + 184
5 QuartzCore 0x1892e7ad0 CA::Layer::layout_if_needed(CA::Transaction*) + 332
6 QuartzCore 0x18925431c CA::Context::commit_transaction(CA::Transaction*) + 336
7 QuartzCore 0x18927bb40 CA::Transaction::commit() + 540
8 QuartzCore 0x18927c980 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 92
9 CoreFoundation 0x185246cdc __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
10 CoreFoundation 0x185244694 __CFRunLoopDoObservers + 412
11 CoreFoundation 0x185164c78 CFRunLoopRunSpecific + 468
12 WebCore 0x18d0d984c RunWebThread(void*) + 560
13 libsystem_pthread.dylib 0x184ec82b4 _pthread_body + 308
14 libsystem_pthread.dylib 0x184ec8180 _pthread_body + 310
15 libsystem_pthread.dylib 0x184ec6b74 thread_start + 4
When running my app I occasionally get this crash that seems not to have anything with my code. What is it and how my I avert it?
Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0
Crashed: 0 libsystem_kernel.dylib 0x000000018fc4c16c
mach_msg_trap + 8 1 libsystem_kernel.dylib
0x000000018fc4bfdc mach_msg + 72 2 AudioToolbox
0x0000000193c8bcdc ASClient_AudioSessionSetActiveWithFlags + 132 3
AudioToolbox 0x0000000193c6c7f4
AudioSessionSetActive_Priv + 360 4 AVFAudio
0x00000001aa46bf8c -[AVAudioSession setActive:withOptions:error:] +
84 5 Jam Session 0x00000001000d41b8 0x1000b0000 +
147896 6 Jam Session 0x00000001000d53fc
0x1000b0000 + 152572 7 UIKit
0x0000000196ae90ec -[UIViewController loadViewIfRequired] + 1056 8
UIKit 0x0000000196ba2cdc
-[UINavigationController _layoutViewController:] + 72 9 UIKit 0x0000000196ba2bb4 -[UINavigationController
_updateScrollViewFromViewController:toViewController:] + 416 10 UIKit 0x0000000196ba1efc -[UINavigationController
_startTransition:fromViewController:toViewController:] + 140 11 UIKit 0x0000000196ba1948 -[UINavigationController
_startDeferredTransitionIfNeeded:] + 856 12 UIKit 0x0000000196ba14fc -[UINavigationController viewWillLayoutSubviews]
+ 64 13 UIKit 0x0000000196ba1460 -[UILayoutContainerView layoutSubviews] + 188 14 UIKit 0x0000000196ae625c -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
+ 1196 15 QuartzCore 0x0000000193fad2c8 -[CALayer layoutSublayers] + 148 16 QuartzCore
0x0000000193fa1fa4 CA::Layer::layout_if_needed(CA::Transaction*) +
292 17 QuartzCore 0x0000000193fa1e64
CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 32 18
QuartzCore 0x0000000193f1eb20
CA::Context::commit_transaction(CA::Transaction*) + 252 19 QuartzCore
0x0000000193f45f8c CA::Transaction::commit() + 512 20 QuartzCore
0x0000000193f469ac
CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned
long, void*) + 120 21 CoreFoundation
0x0000000190c4a7dc
__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 32 22 CoreFoundation 0x0000000190c4840c
__CFRunLoopDoObservers + 372 23 CoreFoundation 0x0000000190b77068 CFRunLoopRunSpecific + 476 24 UIKit
0x0000000196b542ec -[UIApplication _run] + 608 25 UIKit
0x0000000196b4f070 UIApplicationMain + 208 26 Jam Session
0x00000001000c36d4 0x1000b0000 + 79572 27 libdyld.dylib
0x000000018fb585b8 start + 4
I came across this issue today after subclassing a UIView. To resolve this I did the following:
Add an Exception Breakpoint for all exceptions
Enable Zombie Objects
After viewing the thread stack on the left pane, I noticed something related to "key path" and "value".. then I realised that when creating my subclass, I'd created an IBInspectable and updated this value in the storyboard. I later removed this and this is what caused the crash, because the class was still trying to set this value at runtime.
So make sure to check your "User Defined Runtime Attributes".
This crash occurs when using NSNotificationCenter
You registered a notification observer to an object that has been released and didn't removed the observer. So when it tries to call the selector it crashes.
If you are using a ViewController of some kind, you can add
[[NSNotificationCenter defaultCenter] removeObserver:self name:#"Notification" object:nil];
to the viewWillDisappear
if it is not a ViewController you can use -(void) dealloc to unregister the Observer.
In case you to debug further to exactly figure out the point of origin of crash. Put an exception breakpoint in the breakpoints tab and run the app, do casual testing and see if you get the crash.
This should work..
Cheers!
It is the error shown in the Xcode when i switch back to settings in simulator .if somebody knows please kindly notify me. Thanks in advance
GeoNet[2325:41287] This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release.
Stack:(
0 CoreFoundation 0x00c5ba14 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0071ce02 objc_exception_throw + 50
2 CoreFoundation 0x00c5b93d +[NSException raise:format:] + 141
3 Foundation 0x004ee74b _AssertAutolayoutOnMainThreadOnly + 96
4 Foundation 0x003164c1 -[NSISEngine optimize] + 67
5 Foundation 0x00316f84 -[NSISEngine withBehaviors:performModifications:] + 245
6 Foundation 0x0031a404 -[NSISEngine withAutomaticOptimizationDisabled:] + 48
7 UIKit 0x01dd9b08 -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 75
8 UIKit 0x01dda781 -[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded] + 278
9 UIKit 0x01aa48b8 -[UITableViewCellContentView updateConstraintsIfNeeded] + 185
10 UIKit 0x01ddb66c -[UIView(AdditionalLayoutSupport) _updateConstraintsAtEngineLevelIfNeeded] + 372
11 UIKit 0x014a919a -[UIView(Hierarchy) _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] + 173
12 UIKit 0x014a9929 -[UIView(Hierarchy) layoutSubviews] + 184
13 UIKit 0x014bb008 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 810
14 libobjc.A.dylib 0x00731059 -[NSObject performSelector:withObject:] + 70
15 QuartzCore 0x0603480a -[CALayer layoutSublayers] + 144
16 QuartzCore 0x060284ee _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 388
17 QuartzCore 0x06028352 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
18 QuartzCore 0x0601ae8b _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 317
19 QuartzCore 0x0604ee03 _ZN2CA11Transaction6commitEv + 561
20 QuartzCore 0x0604f1ab _ZN2CA11Transaction14release_threadEPv + 289
21 libsystem_pthread.dylib 0x0308d2f7 _pthread_tsd_cleanup + 93
22 libsystem_pthread.dylib 0x0308d051 _pthread_exit + 108
23 libsystem_pthread.dylib 0x0308d734 pthread_get_stackaddr_np + 0
24 libsystem_pthread.dylib 0x0308ae0e start_wqthread + 30
)
This is happening since iOS 9, on earlier version your code could have working fine. This is because, some of your functions must executing on the background thread and after view load trying to change the appearance of view. So, you must have put that function on main thread and load it asynchronously. Please share the code of ViewController, which you are trying to load for more specific answer.
dispatch_async(dispatch_get_main_queue(), ^{
// your code here
})
Been encountering this error a lot in my OS X using swift: "This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release."
See this link, You can find solution.
I've got a crash like the following:
Date/Time: 2015-11-23 19:40:34.34 -0600
Launch Time: 2015-11-23 18:49:43.43 -0600
OS Version: iOS 9.1 (13B143)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000c
Triggered by Thread: 7
Thread 7 Crashed:
0 libobjc.A.dylib 0x34fcbac6 objc_msgSend + 6
1 UIFoundation 0x31e7242e +[NSStringDrawingTextStorageSettings threadSpecificStringDrawingTextStorageSettings:] + 62
2 UIFoundation 0x31e675de +[NSString(NSStringDrawing) typesetterBehavior] + 34
3 UIFoundation 0x31e68ae2 __NSStringDrawingEngine + 298
4 UIFoundation 0x31e68908 -[NSString(NSExtendedStringDrawing) drawWithRect:options:attributes:context:] + 144
5 UIKit 0x276aa488 -[UILabel _drawTextInRect:baselineCalculationOnly:] + 4864
6 UIKit 0x2771b40c -[UILabel drawTextInRect:] + 540
7 UIKit 0x2771b1e4 -[UILabel drawRect:] + 88
8 UIKit 0x2771b15e -[UIView(CALayerDelegate) drawLayer:inContext:] + 386
9 QuartzCore 0x26f8b6fc -[CALayer drawInContext:] + 228
10 QuartzCore 0x26f75088 CABackingStoreUpdate_ + 1852
11 QuartzCore 0x270619d0 ___ZN2CA5Layer8display_Ev_block_invoke + 52
12 QuartzCore 0x26f745c8 CA::Layer::display_() + 1168
13 QuartzCore 0x26f588a0 CA::Layer::display_if_needed(CA::Transaction*) + 204
14 QuartzCore 0x26f58560 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 24
15 QuartzCore 0x26f57a78 CA::Context::commit_transaction(CA::Transaction*) + 368
16 QuartzCore 0x26f5772a CA::Transaction::commit() + 614
17 QuartzCore 0x26f84ed2 CA::Transaction::release_thread(void*) + 310
18 libsystem_pthread.dylib 0x3589e54c _pthread_tsd_cleanup + 508
19 libsystem_pthread.dylib 0x3589e14e _pthread_exit + 86
20 libsystem_pthread.dylib 0x3589db3c _pthread_wqthread + 1044
21 libsystem_pthread.dylib 0x3589d718 start_wqthread + 8
I understand I need to execute the UIKit code on the main thread. However, I'm struggling with what exactly needs to be on the main thread. Do I need to make sure a declaration like the following is done on the main thread:
UIView *lineView;
or only the modifications like the following:
lineView = [[UIView alloc] initWithFrame:CGRectMake(15, cell.contentView.frame.size.height - 1.0, cell.contentView.frame.size.width, 1)];
I've been wrapping things in dispatch code and I'm still getting the same crash.
Thanks.
You should run on UI thread only code that shows something to user.
lineView = [[UIView alloc] initWithFrame:CGRectMake(15, cell.contentView.frame.size.height - 1.0, cell.contentView.frame.size.width, 1)];
this code you can run on background thread, but
[superview addSubview: lineView];
Should be executed on main thread.
I have been getting a rare crash in my app. I am able to track it via hockey app tool integrated with the app. But, unfortunately i am not able to find out any clue about it so as to resolve it.
The crash is happening in the main method of my application in thread 0. I would like to post the stack trace for better analysis. Here it is.
Thread 0 Crashed:
0 libobjc.A.dylib 0x34ed7f46 _objc_msgSend + 6
1 UIKit 0x2ac884cf -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 472
2 UIKit 0x2ac88593 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 52
3 UIKit 0x2ac7dd21 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2266
4 UIKit 0x2aa962df -[UITableView layoutSubviews] + 184
5 UIKit 0x2a9c0677 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 512
6 QuartzCore 0x2a3e8ccd -[CALayer layoutSublayers] + 134
7 QuartzCore 0x2a3e46b5 CA::Layer::layout_if_needed(CA::Transaction*) + 358
8 QuartzCore 0x2a3e453d CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 14
9 QuartzCore 0x2a3e3f21 CA::Context::commit_transaction(CA::Transaction*) + 222
10 QuartzCore 0x2a3e3d25 CA::Transaction::commit() + 322
11 UIKit 0x2ac0bc43 _UIWindowUpdateVisibleContextOrder + 208
12 UIKit 0x2ac0bad5 +[UIWindow _prepareWindowsPassingTestForAppResume:] + 14
13 UIKit 0x2ac2c8f3 -[UIApplication _updateSnapshotAndStateRestorationArchiveForBackgroundEvent:saveState:exitIfCouldNotRestoreState:] + 200
14 UIKit 0x2ac2bda3 __80-[UIApplication _handleNonLaunchSpecificActions:forScene:withTransitionContext:]_block_invoke_2 + 112
15 libdispatch.dylib 0x3542b8cb _dispatch_call_block_and_release + 8
16 libdispatch.dylib 0x3542b8b7 _dispatch_client_callout + 20
17 libdispatch.dylib 0x3542f0bf __dispatch_main_queue_callback_4CF + 723
18 CoreFoundation 0x274eabe9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 6
19 CoreFoundation 0x274e92e9 __CFRunLoopRun + 1510
20 CoreFoundation 0x27437621 _CFRunLoopRunSpecific + 477
21 CoreFoundation 0x27437433 _CFRunLoopRunInMode + 107
22 GraphicsServices 0x2e7bd0a9 _GSEventRunModal + 137
23 UIKit 0x2aa22359 _UIApplicationMain + 1441
The crash being in the main thread, i don't get any clue of where and how to start tracing this crash.
Any help would be highly appreciated.