Crash in SessionDelegate.swift line 93 - kingfisher

I am experiencing a crash when invoking cancelDownloadTask()
Do you have any idea whether the crash might be caused by Kingfisher?
Crashlog
I'm using Kingfisher 5.0.1 and I'm calling function from Deprecated.swift
public func setImage(with resource: Resource?,
placeholder: Placeholder? = nil,
options: KingfisherOptionsInfo? = nil,
progressBlock: DownloadProgressBlock? = nil,
completionHandler: CompletionHandler?) -> DownloadTask?
Unfortunately the reproduction is quite low and I am loading many small images.
Have you ever encountered such issue with the library? HttpParser is very strange at the beginning of the crashlog. Do you have any idea what might be the cause of it.
Regards
Greg

Related

"target is not running or doesn't have entitlement" message: is this connected to crashes?

Update: this problem is more focused now, and not on quite the same topic. I've asked this question as a follow-on
ORIGINAL QUESTION:
I am getting a crash on a subclassed WKWebView-provisioned app.
ProcessAssertion::acquireSync Failed to acquire RBS assertion 'ConnectionTerminationWatchdog' for process with PID=87121, error: Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}
The problem is, that I can't tell if this is related or not. The actual error on crash is
Thread 1: EXC_BAD_ACCESS (code=1, address=0xbdb2dfcf0470)
Which I was assuming was something running off the end of an array. This makes some sense: I'm selecting from a table that filters out some entries from the data source; but I've checked that carefully; there is no point when a row index greater than the actual rows is accessed (and yes, I'm accounting for the difference between count and index).
The main change here is that I previously had a UIView that acted as a container for a number of CAShapeLayers. I also wanted to overlay text view, but with the proviso that this be via a WKWebView. With two separate views, I would have to either have the CAShapeLayer objects in front of, or behind the WebView. I was seeking a fix to that.
What I have done is substitute a WKWebView for the original UIView. I can add the CAShapes to it, so it performs the original function. It also can, presumably, display the html. And the original suggestion in this answer to a question I asked is what I am working towards. The idea being that it would allow the effect sought, with shapes in front of or behind the html elements.
But the error is thrown after the DidSelect call on the table:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
Tracker.track("getting row \(indexPath.row)")
let ptv = tableView as? NovilloTableView
if ptv!.uiType == .textTable {
let gp = Projects.currentProject?.getPaths(type: PaletteView.getCurrentPane())
GitPaths.currentGitPath = gp![indexPath.row]
NotificationCenter.default.post(name: NNames.updateWebText.nn(), object: nil)
return
}
let svgs = Projects.currentProject!.getPaths(type : PaletteView.getCurrentPane())
var gitPath = svgs[indexPath.row]
var gitPaths = GitPaths.getMediaBoundingBoxes(paths: [gitPath])
guard let pathArrays = gitPath.parseForRegBeziers() else { return }
let rslt = pathArrays.0
let regBeziers = pathArrays.1
gitPath.boundingBox = gitPath.getBoundsParamsForPaths(src: regBeziers.isEmpty ? rslt : regBeziers)
GitPaths.currentGitPath = gitPath
// Tracker.track("sending notification")
NotificationCenter.default.post(name: NNames.updateMedia.nn(), object: nil,
userInfo: ["path" : gitPath])
Tracker.track("completed didSelect")
return
}
In other words, the interaction has ended; but I get this crash, even though I can se that the expected result (the rendering of the shapes into the view) has been completed correctly. It seems to be happening right after everything has completed, and no amount of breakpoints has shown anything else to be happening.
This is confusing to me, and I have hit a limit on what I know how to do to dig further into this. Given the nature of web connections, I've wondered if it's some asynchronous issue that I can't debug sequentially; but that's guesswork without any direct evidence.
I suspect that there is a possible configuration problem with the WebView that shows up once I interact with it, by changing its contents. I'm not actually trying to get it to load anything when it crashes, it's only performing its original function as a container for the CAShapeLayers, so I'm confused.
The main view that contains the WKWebView (which is subclassed, to support a function to determine if it should display the web content, and which I've commented out), is set as the delegate for the WKWebView, and that seems to be fine, though there are no actual protocol functions added to that view, not sure if that matters.
The other detail is that the WebView when it does load web content is only loading local text, and not connected to any services. This testing is happening in the Simulator, and I've come across advice elsewhere to allow for background processes that include enabling Background Fetch, etc., but this has done nothing to change the situation...
EDIT: this is the extent of the configuration of the subclassed WKWebView: maybe this is the issue?
mediaDisplay = NovilloWebView()
mediaPane.addSubview(mediaDisplay)
mediaDisplay.navigationDelegate = self
mediaDisplay.uiDelegate = self
mediaDisplay.backgroundColor = .clear

AXRuntimeCommon AX Lookup problem - errorCode:1100 error:Permission denied

I am getting an error message in debug window in Xcode that says "[AXRuntimeCommon] AX Lookup problem - errorCode:1100 error:Permission denied". It comes after the code:
presentingViewController.present(cloudSharingController, animated: true, completion: nil)
The error message usually comes after the cloudSharingControllerDidSaveShare(_ csc: UICloudSharingController) callback method of UICloudSharingControllerDelegate.
When I look for this error on the internet including on stackoverflow it often occurs when a the present method is called for presenting a specialized Apple subclass of UIViewController such as MFMailComposeViewController. One solution suggested was tho encase the present method in DispatchQueue.main.async { }, such as:
mainQueue.async {
presentingViewController.present(cloudSharingController, animated: true, completion: nil)
}
I have tried that and even encase the entire function definition of my function that uses UICloudSharingController and also the present method.
It seems in a lot of cases this error occurs when using networking API's, usually API's that are third-party to Apple.

Why is FileHandle inconsistently returning 'nil'

I have an app which is inconsistently returning 'nil' when using FileHandle to open a file for Read. I'm on OSX (10.13.4), XCode 9.4, Swift 4.1
This OSX app uses the NSOpenPanel() to get a list of files selected by the user. My 'model' class code opens these files to build a collection of data structures The code which does this starts out like this and successfully gets a FileHandle EVERY TIME for any file and is able to read data from the file.
private func getFITHeader(filename: String) {
let file: FileHandle? = FileHandle(forReadingAtPath: filename)
if file == nil {
print("FITFile >>> File open failed for file \(filename)")
}
else {
var databuffer: Data
databuffer = (file?.readData(ofLength: 80))!
:
:
}
The files also contain a block of binary data which I process in another part of the app. While I develop the code for this I'm temporarily hard coding one of the same filenames as works above for test purposes. BUT this code (below) ALWAYS throws an exception 'Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value' when it gets to fileHandle?.seek() - for some reason the attempt to create a FileHandle is always returning 'nil' despite the code being functionally identical to tha above.
#IBAction func btnProcFile(_ sender: Any) {
var data: Data
let filename = "/Users/johncneal/Dropbox/JN Astronomy/Astronomy/Spectroscopy/RSpec_Analyses/Gamma_Cas/20161203/Gamma Cas_065.fit"
let fileHandle: FileHandle? = FileHandle(forReadingAtPath: filename)
fileHandle?.seek(toFileOffset: 2880) //skip past the headers
let dataLenToRead = 1391 * 1039 * 2
data = (fileHandle?.readData(ofLength: dataLenToRead))!
:
:
}
The code in the second function works fine in a Playground (not attaching too much meaning to that) and, wierdly, has also worked when temporarily added to a different project. Probably also worth mentioning the length of the file path doesn't seem to matter - it behaves the same on short paths.
So the question is - why is this behaviour of FileHandle reliably inconsistent?
print()'ing the filenames presented to FileHandle() showed they were identical in each case (see below). So I'm stumped and frustrated by this - any perspectives or workarounds would be appreciated.
/Users/johncneal/Dropbox/JN Astronomy/Astronomy/Spectroscopy/RSpec_Analyses/Gamma_Cas/20161203/Gamma Cas_065.fit
/Users/johncneal/Dropbox/JN Astronomy/Astronomy/Spectroscopy/RSpec_Analyses/Gamma_Cas/20161203/Gamma Cas_065.fit
Found the answer - Sandboxing !!
Darren - coincidentally I did look at the URL based route and discovering it 'throws' put some proper error reporting in the catches. Low and behold they reported I didn't have permissions on the file (which initially surprised me since I'm obviously admin on my Mac's and all the files ar local and under my username.
I bit more research turned up. this article - https://forums.developer.apple.com/thread/96062 which quickly revealed its a sandboxing problem :-) Looks like recent versions of XCode have it turned on in 'Entitlements'. The post also points out that the NSOpenPanel FileOpen dialog returns 'Security scoped urls'. At first I thought this explained why the code in the first function worked but I'm not totally convinced because I was only feeding the url.path property to FileHandle.
However, turning off Sandbox in Entitlements makes everything work just fine. Yes, I know thats not the right thing to do longer term (or if I want this to go to the App Store) so I'll be checking out the right way to do this. At least I can get on now - thanks for the input.
The FileHandle initializers are not well named.
You should use FileHandle(forReadingFrom:URL) instead of FileHandle(forReadingAtPath:String). The former is newer API that throws an error instead of returning nil. You can use the thrown error to see why it is failing, and your variables are guaranteed to be non-nil.
For example:
#IBAction func btnProcFile(_ sender: Any) {
do {
let fileUrl = URL(fileURLWithPath:"/Users/johncneal/Dropbox/JN Astronomy/Astronomy/Spectroscopy/RSpec_Analyses/Gamma_Cas/20161203/Gamma Cas_065.fit")
let fileHandle = try FileHandle(forReadingFrom: fileUrl)
fileHandle.seek(toFileOffset: 2880) //skip past the headers
let dataLenToRead = 1391 * 1039 * 2
let data: Data = fileHandle.readData(ofLength: dataLenToRead)
// etc...
} catch let error as NSError {
print("FITFile >>> File open failed: \(error)")
NSApp.presentError(error)
}
}

Unable to enable precision landing via api call

I'm working with a Phantom 4 Pro drone, which have precision landing capacity. I'm using Swift and a iPad for controlling the drone. In DJI Go software, I can enable it, and it works correctly. However, in the app that I'm working on, any calls to enable it fails.
This is the code that tries to enable it:
static func setPrecisionLandingEnabled(precisionLandingEnabled: Bool, _ completeFunction: #escaping (Error?) -> Void) throws {
guard let djiKeyManager = DJISDKManager.keyManager() else {
GLog.Log("Error in Flight Controller Observer. Problem getting djiKeyManager in \(#file) \(#function)")
throw FlightControllerManager.FlightControllerError.cantGetKeyManager
}
guard let precisionLandingEnabledKey = DJIFlightControllerKey(param: DJIFlightAssistantParamPrecisionLandingEnabled) else {
GLog.Log("Error in Flight Controller Observer. Problem getting precisionLandingEnabledKey in \(#file) \(#function)")
throw FlightControllerManager.FlightControllerError.cantGetKey
}
djiKeyManager.setValue(precisionLandingEnabled, for: precisionLandingEnabledKey, withCompletion: completeFunction)
}
When I call the function, the completion function of DJI SDK returned the following error:
Error Domain=DJISDKErrorDomain Code=-1013 \"Current product does not
support this feature.(code:-1013)\"
The API in question is found here: https://developer.dji.com/api-reference/ios-api/Components/IntelligentFlightAssistant/DJIIntelligentFlightAssistant.html?search=precision&i=0&#djiintelligentflightassistant_setprecisionlandingenabled_inline
I checked, and there's no parameters passed in when issuing the "take-off" call that is related to precision landing. So, why am I getting this error when I know that the drone have this feature (as verified by DJI's own app)? Does the drone have to be flying first before enabling this? Or are there other conditions that must be met before I can enable this?
It looks to me like you should be creating a DJIFlightAssistant object, and then using the existing method setPrecisionLandingEnabled(_: Bool, completion: DJICompletionBlock)
Why are you writing your own setPrecisionLandingEnabled() method?

Xcode 8 random command failed due to signal segmentation fault 11

I have a strange problem with the new Xcode 8 (no beta version) and swift3.
Once every other 3-4 times that I compile my code I get a 'command failed due to signal segmentation fault 11' error. I just need to enter new empty line, or sometimes changing some spaces, or add a comment (everywhere in the code) and the error disappears and I can compile again.
This is really strange because I'm not changing anything in the code! And sometimes I can compile and it works, then I don't change anything, I compile again and I get the error.
This is really annoying!
I have noticed this is happening since I have installed several 'Firebase' pods (Firebase, Firebase/Auth etc...). But I need them.
Anyone has any suggestion?
PS: I have set the Enable Bitcode of my project to No as many solution suggested, but nothing. In the error message it is not indicated any swift page where the error can be, an example is:
While loading members for 'Class_name' at
While deserializing 'func_name' (FuncDecl #42)
'func_name' is this one:
public class func loginUser(fir_user: FIRUser) {
let user = SFUser()
user.email = fir_user.email
user.isLogged = true
try! sfRealm.write() {
sfRealm.add(user, update:true)
}
var userToAdd = [String:AnyObject]()
userToAdd["email"] = fir_user.email! as NSString
let ref=FIRDatabase.database().reference()
let usersRef = ref.child(childName)
usersRef.setValue([key:value])
}
But then, as I said, I can just enter an empty row in another file and it compiles!
Thanks
I have the same issue i just figure out that i was using xcode 8.1 and the project's working copy was in xcode 8.2.1 so i just re install xcode 8.2.1 and problem got solved. Hope other can get the help trough this.
Ok, it seems that I have found the solution: it is a problem with Firebase and cocoapods, so 2 solutions:
Download Firebase and import into your project
I, instead, updated cocoapods to the last version and it worked. Upgraded Firebase - Now Getting Swift Compile Error
In my case there was some type checking issue deep down the compiler so the editor didn't give error in the gutter but on building the project I was getting signal setmentation fault 11 error:
1. While type-checking 'GetStoreAPIRequestModel' at /Users/.../StoreAPIModel.swift:9:1
2. While type-checking expression at [/Users/.../StoreAPIModel.swift:15:18 - line:15:31] RangeText="[Dictionary]()"
3. While resolving type [Dictionary] at [/Users/.../StoreAPIModel.swift:15:18 - line:15:29] RangeText="[Dictionary]"
So I changed my code from:
var stores = [Dictionary]() {
willSet {
allStores.removeAll()
for model in newValue {
allStores.append(StoreAPIModel(dictionary: model as! Dictionary).getModel())
}
}
}
To (more descriptive dictionary):
var stores = [[String : Any]]() {
willSet {
allStores.removeAll()
for model in newValue {
allStores.append(StoreAPIModel(dictionary: model as [String : AnyObject]).getModel())
}
}
}
This is tricky problem. Issue can be with line of code or syntax. I was getting similar error and it was due to incorrect usage of dictionary. I was trying to increment the value of dictionary element.
Solution is to triage the code, detailed error provide which module has issue, so try commenting part of code until you find the line which is causing the issue.
Hi i had the same issue with FireBase , my problem was that i was extending FIRStorageReference and FIRDatabaseReference and some time it compile successfully some time i get
command failed due to signal segmentation fault 11
so i removed that files and implement the method other way , now everything works fine.
Found my problem when this occurred. (No cocoapods.) I thought I had left the program in a working state, but I was wrong. I am writing a straightforward command-line program. What it does is somewhat general, so I defined all the strings that make it specific in let statements at the top of the program so that I could someday use the program in a different context.
Since that was working so well, I thought I'd be clever and do the same with a filter of an array of dictionaries. I turned:
list.filter { $0["SearchStrings"] == nil }
into:
let test = { $0["SearchStrings"] == nil }
// ...
list.filter(test)
meaning to continue working on the let, but I never went back and did that. Building gave me the segmentation fault error. Defining test as a function fixed the problem.
(Incidentally, I understand how to strip a filtering function down to the terse braces notation in the context of the call to Array.filter, and why that works, but I don't understand why I can't assign the brace expression to a constant and use it as such.)