My iOS Simulator crashes when I try to use a UITapGestureRecognizer.
This is my Gesture:
UITapGestureRecognizer tap = new UITapGestureRecognizer (new NSAction(delegate {
if(SettingsTapped != null){
SettingsTapped(this, EventArgs.Empty);
}
}));
I am adding this Gesture to a UIView and then add this view to a UITableViewCell.
The App crashes after touching the View (every time), showing no Exception.
Her is a Output from the Simulator Log File:
Nov 4 10:49:47 administorsmini xXxXx[11073]: assertion failed: 13E28 12B411: libsystem_sim_trace.dylib + 19982 [BEE53863-0DEC-33B1-BFFB-8F7AE595CC73]: 0x4
Nov 4 10:49:49 administorsmini xXxXx[11073]: Stacktrace:
Nov 4 10:49:49 administorsmini xXxXx[11073]: at <unknown> <0xffffffff>
Nov 4 10:49:49 administorsmini xXxXx[11073]: at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x000a6, 0xffffffff>
Nov 4 10:49:49 administorsmini xXxXx[11073]: at MonoTouch.UIKit.UIApplication.Main (string[],intptr,intptr) [0x00005] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:62
Nov 4 10:49:49 administorsmini xXxXx[11073]: at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x00038] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:46
Nov 4 10:49:49 administorsmini xXxXx[11073]: at xXxXx.Application.Main (string[]) [0x00008] in /Users/Norman/Desktop/xXxXx/xXxXx/Main.cs:17
Nov 4 10:49:49 administorsmini xXxXx[11073]: at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>
Nov 4 10:49:49 administorsmini xXxXx[11073]:
Native stacktrace:
Nov 4 10:49:49 administorsmini xXxXx[11073]:
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
Nov 4 10:49:49 administorsmini com.apple.CoreSimulator.SimDevice.27B5D497-B641-4BCA-8FA0-EF9E28E07143.launchd_sim[10951] (UIKitApplication:com.your-company.xXxXx[0x7041][11073]): Service exited due to signal: Abort trap: 6
Nov 4 10:49:49 administorsmini SpringBoard[10962]: Application 'UIKitApplication:com.your-company.xXxXx[0x7041]' crashed.
Nov 4 10:49:49 administorsmini assertiond[10966]: notify_suspend_pid() failed with error 7
Nov 4 10:49:49 administorsmini assertiond[10966]: assertion failed: 13E28 12B411: assertiond + 11523 [3F572A0B-7E12-378D-AFEE-EA491BAF2C36]: 0x1
What can I do now?
I don´t want to Develop on the Device...
EDIT
I ended up by overriding UIView and use its TouchesBegan() Method.
There are many approaches to make something clickable but why can´t I just use this one above??
Here's a bit of code that I'm using in my application:
private void addTapGesture()
{
imgLogo.UserInteractionEnabled = true;
var tapGesture = new UITapGestureRecognizer(this, new Selector("ResendTrigger:"));
tapGesture.NumberOfTapsRequired = 5;
imgLogo.AddGestureRecognizer(tapGesture);
}
[Export("ResendTrigger:")]
public void ResendTrigger(UIGestureRecognizer sender)
{
System.Diagnostics.Debug.WriteLine("Triggered");}
}
First argument of constructor (this) points to object that contains definition of method with specified Export attribute so if you will define selector and method inside your view NSObject target will be reference of your view if method that you want to call exist for example in cell your cell reference will be the target.EDITBased on comment I assumed that you may be using UITableViewSource . I think your case is similar to mine so try this approach :Declare event in your UITableSource something like public event EventHandler<DataBaseModels.SavedActions> OnActionSelected;Then in getCell assign tap gesture to your view and inside method you will have reference to sender objec, cast it to UIView and retain tag to identify corresponding record
Related
Below is my sample code. Everything working perfectly but if trying to add a new property in PageLoad or TestDetailResponseModel struct then the app is getting crash. There is no issue in API response and parsing. Getting parsed value in the print statement. According to the crash log, it's something related to memory but I am unable to figure it out. Below is my sample code. My API response is approx 40 KB. Please help me.
Note-
I am not mutating the response objects only consuming.
If change PageLoad from struct to class app is not crashing
import RxCocoa
import RxSwift
public struct TestDetailViewModel {
private func getTestDetailSuccessResponse() -> Driver<TestDetailResponseModel?> {
//Make API call asynchronously using RxSwift and storing result in testDetailResponseModel
let testDetailResponseModel: TestDetailResponseModel? = RXNetworkManager.execute(request: MyRequestModel) {
//Api Response
//Parse response. Parsing is proper. responseModel prints all the parsed properties with correct values of TestDetailResponseModel and PageLoad objects (detail, and pageNumber)
print(responseModel)
}
return Driver.just(testDetailResponseModel)
}
private func loadDetail() {
let isDetailExist = getTestDetailSuccessResponse().compactMap { response -> Bool? in
print(response) //No Crash
print(response?.pageLoad) //App crashed here if add pageNumber property in PageLoad object
return response?.pageLoad != nil
}
}
}
public struct TestDetailResponseModel: Decodable {
public let pageLoad: PageLoad?
//...
}
public struct PageLoad: Decodable {
public let detail: String?
//...
public let pageNumber: Double? //New property
}
=================Crash Report for same====================
Exception Type: EXC_BAD_ACCESS (SIGABRT)
Exception Subtype: KERN_INVALID_ADDRESS at 0x50a01fb550981f18 -> 0xffff9fb550981f18 (possible pointer authentication failure)
Exception Codes: 0x0000000000000001, 0x50a01fb550981f18
VM Region Info: 0xffff9fb550981f18 is not in any region. Bytes after previous region: 18446532646169747225
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
MALLOC_NANO (reserved) 600018000000-600020000000 [128.0M] rw-/rwx SM=NUL ...(unallocated)
--->
UNUSED SPACE AT END
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0
Application Specific Information:
=================================================================
==17015==ERROR: AddressSanitizer: SEGV on unknown address 0x50a01fb550981f18 (pc 0x00018f9e1d50 bp 0x00016bbf60c0 sp 0x00016bbf6080 T0)
==17015==The signal is caused by a UNKNOWN memory access.
#0 0x18f9e1d50 in swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::incrementSlow(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int)+0x2c (libswiftCore.dylib:arm64+0x302d50)
#1 0x18f9b20bc in _swift_retain_+0x54 (libswiftCore.dylib:arm64+0x2d30bc)
#2 0x10d8d5edc (liboainject.dylib:arm64+0x5edc)
#3 0x18f9e7958 in swift_bridgeObjectRetain+0x30 (libswiftCore.dylib:arm64+0x308958)
#4 0x1191ab100 in outlined copy of PageLoad?+0x1dc (TestCore:arm64+0x10ff100)
#5 0x1196cf554 in outlined copy of TestDetailResponseModel?+0x6a4 (TestCore:arm64+0x1623554)
#6 0x11a1541bc in TestDetailViewModel.getTestDetailSuccessResponse(response:) TestDetailViewModel+APICalls.swift:69
#7 0x1195240b8 in closure #13 in TestDetailViewModel.transform(input:) TestDetailViewModel.swift:108
#8 0x10e59b30c in CompactMapSink.on(_:) CompactMap.swift:47
#9 0x10e59b550 in protocol witness for ObserverType.on(_:) in conformance CompactMapSink<A, B> <compiler-generated>
#10 0x10e5f91d0 in partial apply for implicit closure #2 in implicit closure #1 in ShareWhileConnectedConnection._synchronized_subscribe<A>(_:) <compiler-generated>
#11 0x10e58d8d8 in thunk for #escaping #callee_guaranteed (#in_guaranteed Event<A>) -> () <compiler-generated>
#12 0x10e5f804c in ShareReplay1WhileConnectedConnection.on(_:)+0x70 (RxSwift:arm64+0x8804c)
#13 0x10e5f7bf4 in protocol witness for ObserverType.on(_:) in conformance ShareReplay1WhileConnectedConnection<A> <compiler-generated>
#14 0x10e5b0514 in Sink.forwardOn(_:) Sink.swift:34
#15 0x10e582398 in SwitchSinkIter._synchronized_on(_:) Switch.swift:160
#16 0x10e5abb68 in SynchronizedOnType.synchronizedOn(_:) SynchronizedOnType.swift:16
#17 0x10e582488 in protocol witness for ObserverType.on(_:) in conformance SwitchSinkIter<A, B, C> <compiler-generated>
#18 0x10e5f91d0 in partial apply for implicit closure #2 in implicit closure #1 in ShareWhileConnectedConnection._synchronized_subscribe<A>(_:) <compiler-generated>
#19 0x10e58d8d8 in thunk for #escaping #callee_guaranteed (#in_guaranteed Event<A>) -> () <compiler-generated>
#20 0x10e5f804c in ShareReplay1WhileConnectedConnection.on(_:)+0x70 (RxSwift:arm64+0x8804c)
#21 0x10e5f7bf4 in protocol witness for ObserverType.on(_:) in conformance ShareReplay1WhileConnectedConnection<A> <compiler-generated>
#22 0x10e5b0514 in Sink.forwardOn(_:) Sink.swift:34
#23 0x10e59d0c8 in CatchSink.on(_:) Catch.swift:131
#24 0x10e59d31c in protocol witness for ObserverType.on(_:) in conformance CatchSink<A> <compiler-generated>
#25 0x10e605534 in closure #1 in ObserveOnSerialDispatchQueueSink.init(scheduler:observer:cancel:) ObserveOn.swift:184
#26 0x10e605d48 in partial apply for thunk for #escaping #callee_guaranteed (#guaranteed ObserveOnSerialDispatchQueueSink<A>, #in_guaranteed Event<A.ObserverType.Element>) -> (#out Disposable) <compiler-generated>
#27 0x10e5904e4 in partial apply for closure #1 in MainScheduler.scheduleInternal<A>(_:action:) <compiler-generated>
#28 0x10e585410 in thunk for #escaping #callee_guaranteed () -> () <compiler-generated>
#29 0x1139f950c in __wrap_dispatch_async_block_invoke+0xb8 (libclang_rt.asan_iossim_dynamic.dylib:arm64+0x3d50c)
#30 0x18010d240 in _dispatch_call_block_and_release+0x14 (libdispatch.dylib:arm64+0x2240)
#31 0x18010ea94 in _dispatch_client_callout+0xc (libdispatch.dylib:arm64+0x3a94)
#32 0x18011c418 in _dispatch_main_queue_drain+0x3cc (libdispatch.dylib:arm64+0x11418)
#33 0x18011c038 in _dispatch_main_queue_callback_4CF+0x24 (libdispatch.dylib:arm64+0x11038)
#34 0x180361c28 in __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__+0x8 (CoreFoundation:arm64+0x85c28)
#35 0x18035c0ac in __CFRunLoopRun+0x97c (CoreFoundation:arm64+0x800ac)
#36 0x18035b214 in CFRunLoopRunSpecific+0x238 (CoreFoundation:arm64+0x7f214)
#37 0x18c25f608 in GSEventRunModal+0x9c (GraphicsServices:arm64+0x3608)
#38 0x184d88a94 in -[UIApplication _run]+0x3dc (UIKitCore:arm64+0xc0da94)
#39 0x184d8d630 in UIApplicationMain+0x6c (UIKitCore:arm64+0xc12630)
#40 0x104dc5958 in main AppDelegate.swift:32
#41 0x10b66dcd4 in start_sim+0x10 (dyld_sim:arm64+0x1cd4)
#42 0x10b71d084 (<unknown module>)
#43 0xa777ffffffffffc (<unknown module>)
==17015==Register values:
x[0] = 0x000000018035ba08 x[1] = 0xaa1403f6aa1303e1 x[2] = 0x0000000000000001 x[3] = 0x0000000000000001
x[4] = 0x0000000000000000 x[5] = 0x0000000000000000 x[6] = 0x0000000000000000 x[7] = 0x0000000000000000
x[8] = 0x50a01fb550981f08 x[9] = 0x000000018035ba00 x[10] = 0xffffffffffffffff x[11] = 0xaa1403f8aa1303e1
x[12] = 0x0000000000000000 x[13] = 0x0000000000000000 x[14] = 0x0000000000000000 x[15] = 0x0000000000000000
x[16] = 0x00000001cc0ac98c x[17] = 0x0000000000000000 x[18] = 0x0000000000000000 x[19] = 0x000000016bbf6118
x[20] = 0x000000018035ba00 x[21] = 0x000000010d8dc000 x[22] = 0x000000016bbf60f8 x[23] = 0x000000010d8dc000
x[24] = 0x000000010d8dc000 x[25] = 0x0000000000000000 x[26] = 0x40c1d7097c1bda51 x[27] = 0x4000000153eb88d0
x[28] = 0xc000000000000030 fp = 0x000000016bbf60c0 lr = 0x000000018f9b20c0 sp = 0x000000016bbf6080
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (libswiftCore.dylib:arm64+0x302d50) in swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::incrementSlow(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int)+0x2c
==17015==ABORTING
dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode_13.4.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot DYLD_INSERT_LIBRARIES=/Applications/Xcode_13.4.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/DVTInstrumentsFoundation.framework/liboainject.dylib
CoreSimulator 802.6.1 - Device: iPhone 13 Pro Max (********-****-****-****-************) - Runtime: iOS 15.5 (19F70) - DeviceType: iPhone 13 Pro Max
dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode_13.4.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot DYLD_INSERT_LIBRARIES=/Applications/Xcode_13.4.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/DVTInstrumentsFoundation.framework/liboainject.dylib
abort() called
Kernel Triage:
VM - Compressor failed a blocking pager_get
VM - Compressor failed a blocking pager_get
VM - Compressor failed a blocking pager_get
VM - Compressor failed a blocking pager_get
There is not much information, but I can guess what the problem is
Any Api call asynchronous, and you need use #escaping completion for handle result of dataTask
private func getTestDetailSuccessResponse(completion: #escaping (TestDetailResponseModel>)->Void) {
var testDetailResponseModel: TestDetailResponseModel?
// Make api call
// return result of call into completion as "completion(result)"
}
Using:
private func loadDetail() {
getTestDetailSuccessResponse { result in
let detail = result?.pageLoad
}
}
I am having a crash only on one specific scene in my AR Foundation Unity build with the following error.
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000020
VM Region Info: 0x20 is not in any region. Bytes before following region: 4362387424
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
__TEXT 10404c000-104050000 [ 16K] r-x/r-x SM=COW ...lycoroTestApp
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [5380]
Triggered by Thread: 28
Thread 28 name:
Thread 28 Crashed:
0 libobjc.A.dylib 0x0000000195ac5ac0 objc_retain + 16 (objc-object.h:636)
1 UnityFramework 0x00000001066d5320 TexturesMetal::AddCreatedTexture(TextureID, id, bool) + 32 (TexturesMetal.mm:481)
2 UnityFramework 0x0000000106634828 GfxDeviceWorker::RunCommand(ThreadedStreamBuffer&) + 21972 (GfxDeviceWorker.cpp:0)
3 UnityFramework 0x00000001066aa2ec GfxDeviceWorkerAutoreleasePoolProxy + 68 (GfxDeviceMetal.mm:5242)
4 UnityFramework 0x0000000106636bd0 GfxDeviceWorker::RunExt(ThreadedStreamBuffer&) + 92 (GfxDeviceWorker.cpp:389)
5 UnityFramework 0x0000000106636b68 GfxDeviceWorker::Run() + 156 (GfxDeviceWorker.cpp:373)
6 UnityFramework 0x000000010662ef70 GfxDeviceWorker::RunGfxDeviceWorker(void*) + 12 (GfxDeviceWorker.cpp:352)
7 UnityFramework 0x00000001062289f8 Thread::RunThreadWrapper(void*) + 496 (Thread.cpp:81)
8 libsystem_pthread.dylib 0x00000001c9777c74 _pthread_start + 288 (pthread.c:887)
9 libsystem_pthread.dylib 0x00000001c977c878 thread_start + 8
At first I thought it was because I was missing the Environmental Probe manager in that scene (no). Then I thought perhaps it was because I was using a specific shader that didn't use a _MainTex. But I use that shader no problem in other working scenes.
And then I built the scene with only a simple primitive and my UI and still received this error. After that crash the scene did open successfully, but obviously the problem is still there. The UI is the exact same as the other working scenes.
I can't find out much about this specific error: TexturesMetal::AddCreatedTexture - only that there may be this bug with GLES3 and PVRTC textures - but they aren't present in the most recent build.
https://issuetracker.unity3d.com/issues/ios-crash-in-uploadtexture-at-texturesmeta-dot-mm-or-drawbufferranges-at-gfxdevicegles-dot-cpp-using-atlas-with-pvrtc-compress
The scene works perfectly in Android - it only crashes in iOS.
Any ideas? Full report below.
I ran a Product>Analysis in Xcode and it gave me this warning:
/Users/xcodeclub/Downloads/Eliot Silver/Classes/UI/UnityView.mm:200:5: nil returned from a method that is expected to return a non-null value
For this bit of Code in UnityView.mm:
static Class UnityRenderingView_LayerClassMTL(id self_, SEL _cmd)
{
return NSClassFromString(#"CAMetalLayer");
}
static Class UnityRenderingView_LayerClassNULL(id self_, SEL _cmd)
{
return NSClassFromString(#"CALayer");
}
#implementation UnityRenderingView
(Class)layerClass
{
return nil;
}
(void)InitializeForAPI:(UnityRenderingAPI)api
{
IMP layerClassImpl = api == apiMetal ? (IMP)UnityRenderingView_LayerClassMTL : (IMP)UnityRenderingView_LayerClassNULL;
class_replaceMethod(object_getClass([UnityRenderingView class]), #Selector(layerClass), layerClassImpl, UIView_LayerClass_Enc);
}
#End
I have a Xamarin iOS app, it was working properly, but I don't know what I've touched so it started raising this exception when I click on button to move to another view in storyboard:
System.Exception: Failed to marshal the Objective-C object 0x7ffa72c19570 (type: PropertyListViewController). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance (because the type 'Rental.iOS.PropertyListViewController' does not have a constructor that takes one IntPtr argument).
at at (wrapper managed-to-native) ObjCRuntime.Messaging:void_objc_msgSendSuper_bool_bool (intptr,intptr,bool,bool)
at UIKit.UIViewController.BeginAppearanceTransition (System.Boolean isAppearing, System.Boolean animated) [0x0002c] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/build/ios/native/UIKit/UIViewController.g.cs:168
at XLPagerTabStrip.PagerTabStripViewController.UpdateContent () [0x001c3] in /Users/abd/Programming/Gits/Rental/Rental/Rental/Rental.iOS/XLPagerTabStrip/PagerTabStripViewController.cs:271
at XLPagerTabStrip.PagerTabStripViewController.Scrolled (UIKit.UIScrollView scrollView) [0x0000e] in /Users/abd/Programming/Gits/Rental/Rental/Rental/Rental.iOS/XLPagerTabStrip/PagerTabStripViewController.cs:339
at at (wrapper managed-to-native) ObjCRuntime.Messaging:void_objc_msgSend_CGPoint (intptr,intptr,CoreGraphics.CGPoint)
at UIKit.UIScrollView.set_ContentOffset (CoreGraphics.CGPoint value) [0x00010] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/build/ios/native/UIKit/UIScrollView.g.cs:387
at XLPagerTabStrip.PagerTabStripViewController.UpdateContent () [0x00068] in /Users/abd/Programming/Gits/Rental/Rental/Rental/Rental.iOS/XLPagerTabStrip/PagerTabStripViewController.cs:247
at XLPagerTabStrip.PagerTabStripViewController.Scrolled (UIKit.UIScrollView scrollView) [0x0000e] in /Users/abd/Programming/Gits/Rental/Rental/Rental/Rental.iOS/XLPagerTabStrip/PagerTabStripViewController.cs:339
at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/UIKit/UIApplication.cs:63
at Rental.iOS.Application.Main (System.String[] args) [0x00008] in /Users/abd/Programming/Gits/Rental/Rental/Rental/Rental.iOS/Main.cs:17
What can I check in Interface Designer to make sure I am not doing anything wrong?
I added thhis constructor:
public partial class PropertyListViewController : UIViewController
{
protected PropertyListViewController(IntPtr handle) : base(handle)
{
// Note: this .ctor should not contain any initialization logic.
}
~~~~
}
But now I receive this error :
Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: -[UIViewController _loadViewFromNibNamed:bundle:] loaded the "PropertyListViewController" nib but the view outlet was not set.
Native stack trace:
0 CoreFoundation 0x000000010c73ad4b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000011713a21e objc_exception_throw + 48
2 CoreFoundation 0x000000010c7a42b5 +[NSException raise:format:] + 197
3 UIKit 0x00000001101b6aea -[UIViewController _loadViewFromNibNamed:bundle:] + 679
4 UIKit 0x00000001101b72e7 -[UIViewController loadView] + 177
5 UIKit 0x00000001101b761c -[UIViewController loadViewIfRequired] + 201
6 UIKit 0x00000001101be062 -[UIViewController __viewWillAppear:] + 118
7 Rental.iOS 0x000000010c0c6f9c xamarin_dyn_objc_msgSendSuper + 220
8 ??? 0x0000000130fb7405 0x0 + 5116752901
at at (wrapper managed-to-native) ObjCRuntime.Messaging:void_objc_msgSendSuper_bool_bool (intptr,intptr,bool,bool)
at UIKit.UIViewController.BeginAppearanceTransition (System.Boolean isAppearing, System.Boolean animated) [0x0002c] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/build/ios/native/UIKit/UIViewController.g.cs:168
at XLPagerTabStrip.PagerTabStripViewController.UpdateContent () [0x001c3] in /Users/abd/Programming/Gits/Rental/Rental/Rental/Rental.iOS/XLPagerTabStrip/PagerTabStripViewController.cs:271
at XLPagerTabStrip.PagerTabStripViewController.Scrolled (UIKit.UIScrollView scrollView) [0x0000e] in /Users/abd/Programming/Gits/Rental/Rental/Rental/Rental.iOS/XLPagerTabStrip/PagerTabStripViewController.cs:339
at at (wrapper managed-to-native) ObjCRuntime.Messaging:void_objc_msgSend_CGPoint (intptr,intptr,CoreGraphics.CGPoint)
at UIKit.UIScrollView.set_ContentOffset (CoreGraphics.CGPoint value) [0x00010] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/build/ios/native/UIKit/UIScrollView.g.cs:387
at XLPagerTabStrip.PagerTabStripViewController.UpdateContent () [0x00068] in /Users/abd/Programming/Gits/Rental/Rental/Rental/Rental.iOS/XLPagerTabStrip/PagerTabStripViewController.cs:247
at XLPagerTabStrip.PagerTabStripViewController.Scrolled (UIKit.UIScrollView scrollView) [0x0000e] in /Users/abd/Programming/Gits/Rental/Rental/Rental/Rental.iOS/XLPagerTabStrip/PagerTabStripViewController.cs:339
at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/UIKit/UIApplication.cs:63
at Rental.iOS.Application.Main (System.String[] args) [0x00008] in /Users/abd/Programming/Gits/Rental/Rental/Rental/Rental.iOS/Main.cs:17
PropertyListViewController does not have a constructor that takes one IntPtr argument.
In your UIViewController subclass, add an .ctor like so:
public partial class PropertyListViewController : UIViewController
{
protected PropertyListViewController(IntPtr handle) : base(handle)
{
// Note: this .ctor should not contain any initialization logic.
}
~~~~
}
I've been struggling with a strange problem for two days now. I went through every related question on SO but none solved the issue. I'm working on Xcode5. I'm using ARC and CoreData.
On iOS7 (simulator):
`[CFString release]: message sent to deallocated instance`
Thread 1, Queue : com.apple.main-thread
0 0x03c7d3ba in __kill ()
1 0x03c7c4b8 in kill$UNIX2003 ()
2 0x0347a921 in ___forwarding___ ()
3 0x0347a4ee in _CF_forwarding_prep_0 ()
4 0x02b7b002 in -[NSConcreteAttributedString dealloc] ()
5 0x02f66692 in objc_object::sidetable_release(bool) ()
6 0x02f65e81 in objc_release ()
7 0x02f66ce7 in (anonymous namespace)::AutoreleasePoolPage::pop(void*) ()
8 0x00739bc4 in CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) ()
9 0x0345253e in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()
10 0x0345248f in __CFRunLoopDoObservers ()
11 0x034303b4 in __CFRunLoopRun ()
12 0x0342fb33 in CFRunLoopRunSpecific ()
13 0x0342f94b in CFRunLoopRunInMode ()
14 0x04bd19d7 in GSEventRunModal ()
15 0x04bd17fe in GSEventRun ()
16 0x0196794b in UIApplicationMain ()
17 0x0000262d in main
The Zombies Instruments point to the second line where I set the cell's text labels:
cell.txtLabel.text = _reservationModule.newReservationText;
cell.subtitleTxtLabel.text = _reservationModule.newReservationSubtitle;
_reservationModule is a Core Data entity featuring the string properties. It's defined in the view controller as #property (nonatomic, strong) ReservationModule *reservationModule;
The Zombie history:
Event Type ∆ RefCt RefCt Timestamp Responsible Library Responsible Caller
Malloc/Retain/Release (4) 01:01.114.922 CoreData _prepareResultsFromResultSet
0 Malloc +1 1 01:01.114.922 CoreData _prepareResultsFromResultSet
1 Retain +1 2 01:01.116.184 CoreData -[_CDSnapshot mutableCopy]
2 Release -1 1 01:01.318.588 MyApp -[ReservationModuleChoice2ViewController configureSubtitleImageTableViewCell:atIndexPath:]
3 Release -1 0 01:05.004.359 CoreData -[_CDSnapshot dealloc]
4 Zombie -1 01:07.441.465 CoreData -[_CDSnapshot dealloc]
They've never occurred on Xcode 4.6.x though.
Any help is highly appreciated!
Thanks!
The answer is trivial and hasn't anything to do with retain counters...
I oversaw that it isn't allowed to name variables/properties starting with new with ARC enabled. This obviously resulted in an over release thus generating the error...
From Apple documentation: https://developer.apple.com/library/ios/releasenotes/objectivec/rn-transitioningtoarc/introduction/introduction.html
To allow interoperation with manual retain-release code, ARC imposes a
constraint on method naming:
You cannot give an accessor a name that begins with new. This in turn
means that you can’t, for example, declare a property whose name
begins with new unless you specify a different getter
I use iPhone 6 simulator in Xcode. After I add a simple UITextView in my view, I type some word in it. But I found some errors in console:
Oct 19 10:07:14 localhost textViewTest[1438] <Error>: CGContextSaveGState: invalid context 0x0
Oct 19 10:07:14 localhost textViewTest[1438] <Error>: CGContextDrawLinearGradient: invalid context 0x0
Oct 19 10:07:14 localhost textViewTest[1438] <Error>: CGContextSetFillColorWithColor: invalid context 0x0
Oct 19 10:07:14 localhost textViewTest[1438] <Error>: CGContextFillRects: invalid context 0x0
Oct 19 10:07:14 localhost textViewTest[1438] <Error>: CGContextFillRects: invalid context 0x0
Oct 19 10:07:14 localhost textViewTest[1438] <Error>: CGContextSetFillColorWithColor: invalid context 0x0
Oct 19 10:07:14 localhost textViewTest[1438] <Error>: CGContextFillRects: invalid context 0x0
Oct 19 10:07:14 localhost textViewTest[1438] <Error>: CGContextSaveGState: invalid context 0x0
Oct 19 10:07:14 localhost textViewTest[1438] <Error>: CGContextDrawLinearGradient: invalid context 0x0
Oct 19 10:07:14 localhost textViewTest[1438] <Error>: CGContextSetFillColorWithColor: invalid context 0x0
Oct 19 10:07:14 localhost textViewTest[1438] <Error>: CGContextFillRects: invalid context 0x0
Oct 19 10:07:14 localhost textViewTest[1438] <Error>: CGContextFillRects: invalid context 0x0
Oct 19 10:07:14 localhost textViewTest[1438] <Error>: CGContextSetFillColorWithColor: invalid context 0x0
Oct 19 10:07:14 localhost textViewTest[1438] <Error>: CGContextFillRects: invalid context 0x0
And when I watch the memory use ,it increase very fast.But when I use iphone5 or iphone4.3 Simulator it will not appear.
Here is my code:
#import "ViewController.h"
#include <sys/sysctl.h>
#include <mach/mach.h>
#interface ViewController ()
#end
#implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UITextView *textView=[[UITextView alloc] initWithFrame:CGRectMake(0,0,320,50)];
[self.view addSubview:textView];
[textView release];
NSTimeInterval timeInterval =5.0 ;
[NSTimer scheduledTimerWithTimeInterval:timeInterval
target:self
selector:#selector(handleMaxShowTimer:)
userInfo:nil
repeats:YES];
}
- (double)availableMemory
{
vm_statistics_data_t vmStats;
mach_msg_type_number_t infoCount = HOST_VM_INFO_COUNT;
kern_return_t kernReturn = host_statistics(mach_host_self(),HOST_VM_INFO,(host_info_t)&vmStats,&infoCount);
if(kernReturn != KERN_SUCCESS)
{
return NSNotFound;
}
return ((vm_page_size * vmStats.free_count) / 1024.0) / 1024.0;
}
- (double)usedMemory
{
task_basic_info_data_t taskInfo;
mach_msg_type_number_t infoCount = TASK_BASIC_INFO_COUNT;
kern_return_t kernReturn = task_info(mach_task_self(),
TASK_BASIC_INFO, (task_info_t)&taskInfo, &infoCount);
if(kernReturn != KERN_SUCCESS) {
return NSNotFound;
}
return taskInfo.resident_size / 1024.0 / 1024.0;
}
-(void)handleMaxShowTimer:(NSTimer *)theTimer
{
NSLog(#" use memory %f remain memory %f",[self usedMemory],[self availableMemory]);
}
#end
Your memory usage most likely isn't "increasing like crazy", you just happen to be looking at the total number of bytes allocated in instruments, which is meant to steadily increase. Use the actual leaks tool and it will even tell you the exact line of code the leaks occur at, and how much one particular function is contributing to the overall leakage.
As for the CG... Errors, drawing code needs to be done in a -drawRect: override, which is the only place you can get a stable non-NULL context to draw into.