I am encountering an issue when making an API call using URLSession with DispatchQueue.global(qos: .background).async on a real device running tvOS 18. The code works as expected on tvOS 17 and in the simulator for tvOS 18, but when I remove the debug mode, After the API call it takes few mintues or 5 to 10 min to load the data on the real device.
Code: Here’s the code I am using for the API call:
appconfig.getFeedURLData(feedUrl: feedUrl, timeOut: kRequestTimeOut, apiMethod: ApiMethod.POST.rawValue) { (result) in
self.EpisodeItems = Utilities.sharedInstance.getEpisodeArray(data: result)
}
func getFeedURLData(feedUrl: String, timeOut: Int, apiMethod: String, completion: @escaping (_ result: Data?) -> ()) {
guard let validUrl = URL(string: feedUrl) else { return }
var request = URLRequest(url: validUrl, cachePolicy: .useProtocolCachePolicy, timeoutInterval: TimeInterval(timeOut))
let userPasswordString = "\(KappSecret):\(KappPassword)"
let userPasswordData = userPasswordString.data(using: .utf8)
let base64EncodedCredential = userPasswordData!.base64EncodedString(options: .lineLength64Characters)
let authString = "Basic \(base64EncodedCredential)"
let headers = [
"authorization": authString,
"cache-control": "no-cache",
"user-agent": "TN-CTV-\(kPlateForm)-\(kAppVersion)"
]
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpMethod = apiMethod
request.allHTTPHeaderFields = headers
let response = URLSession.requestSynchronousData(request as URLRequest)
if response.1 != nil {
do {
guard let parsedData = try JSONSerialization.jsonObject(with: response.1!, options: .mutableContainers) as? AnyObject else {
print("Error parsing data")
completion(nil)
return
}
print(parsedData)
completion(response.1)
return
} catch let error {
print("Error: \(error.localizedDescription)")
completion(response.1)
return
}
}
completion(response.1)
}
import Foundation
public extension URLSession {
public static func requestSynchronousData(_ request: URLRequest) -> (URLResponse?, Data?) {
var data: Data? = nil
var responseData: URLResponse? = nil
let semaphore = DispatchSemaphore(value: 0)
let task = URLSession.shared.dataTask(with: request) { taskData, response, error in
data = taskData
responseData = response
if data == nil, let error = error {
print(error)
}
semaphore.signal()
}
task.resume()
_ = semaphore.wait(timeout: .distantFuture)
return (responseData, data)
}
public static func requestSynchronousDataWithURLString(_ requestString: String) -> (URLResponse?, Data?) {
guard let url = URL(string: requestString.checkValidUrl()) else { return (nil, nil) }
let request = URLRequest(url: url)
return URLSession.requestSynchronousData(request)
}
}
Issue Description: Working scenario: The API call works fine on tvOS 17 and in the simulator for tvOS 18. Problem: When running on a real device with tvOS 18, the API call takes time[enter image description here] when debug mode is disabled, but works fine when debug mode is enabled, Data is loading after few minutes.
Error message: Error Domain=WKErrorDomain Code=11 "Timed out while loading attributed string content" UserInfo={NSLocalizedDescription=Timed out while loading attributed string content} NSURLConnection finished with error - code -1001 nw_read_request_report [C4] Receive failed with error "Socket is not connected" Snapshot request 0x30089b3c0 complete with error: <NSError: 0x3009373f0; domain: BSActionErrorDomain; code: 1 ("response-not-possible")> tcp_input [C7.1.1.1:3] flags=[R] seq=817957096, ack=0, win=0 state=CLOSE_WAIT rcv_nxt=817957096, snd_una=275546887
Environment: Xcode version: 16.1 Real device: Model A1625 (32GB) tvOS version: 18.1
Debugging steps I’ve taken: I’ve verified that the issue does not occur in debug mode. I’ve confirmed that the API call works fine on tvOS 17 and in the simulator (tvOS 18). The error suggests a network timeout (-1001) and a socket connection issue ("Socket is not connected").
Questions:
Is this a known issue with tvOS 18 on real devices? Are there any specific settings or configurations in tvOS 18 that could be causing the timeout error in non-debug mode? Could this be related to how URLSession or networking behaves differently in release mode? I would appreciate any help or insights into this issue!
Post
Replies
Boosts
Views
Activity
Creating CSR file from my Mac steps are :-
Going to the Keychain Access > Certificate Assistant > Request a Certificate From a Certificate Authority...
Filling the required details in the field, save to desk then continue and save it desktop.
Then going to the Developer account in Certification screen and creating a new certificate on click on plus icon then selecting Apple distribution > continue , Then uploading CSR file in the required box and continue.
After this I have downloaded the “distribution.cer” file then double clicked on the file then going to the KeyChain Access to see the My Certificate section there is no certificate which I have installed but it showing in the Certificate section without Private key.
This steps I have followed but not getting Private key in my certificate how to correct this issue
System Configuration :-
Mac OS- 14.5
Chip - Apple M1
Keychain Access version - Version 11.0 (55314)
I have an image. The table has many columns and associated rows with it. Is it possible to recognize a particular column's key and values from the table?
To create a new application, I didn't see any warning or error of Alpha related issue during update assets in the app. But I am getting error "Invalid asset files remove alpha from image" during upload this build on Test Flight. So how can resolve this problem? Because I didn’t get any warning in my asset files.
I Have a Apple id of USA and i want publish my application in different region outside of USA so can anyone guide me in this.
i am facing issue using xcode 14.3, the error is
failed to emit precompiled header '/Users/Library/Developer/Xcode/DerivedData/ksl-eyxaasnuhobrniasqskqxatrixxw/Build/Intermediates.noindex/PrecompiledHeaders/TEBridge-Header-swift_YVK8DW4UEVT6-clang_2GLMX79PBJ59I.pch' for bridging header '/Users/Desktop/GA-4For mobile/ott-ios-Latest-16-June/ksl/Utilities/Resources/TEBridge-Header.h'
I am getting this error in my project and I am getting why this is happening can anyone help me in this.
how to implement GA4 without measurement id
how to implement GA4
I am facing build failed error when i build the project in Xcode 14.2 this is running fine can anyone help in this issue.
Thanks
we are facing issue, when uploading video i want to show progress bar with percentage according to video size, i am using didSendBodyData delegate but here we are unable to get call back particular in this delegate and all other delegate is calling properly, if any one face this kind of problem please suggest to me.
Advance thanks
Hello Everyone,
Apple rejects app due to this crash and attached couple of crash logs, from where it hard to find out what's the exact reason behind it, Can anyone help me out.
crashlog-542E9683-FEF0-49D6-A9B5-E92DB6FCAA93.txt
crashlog-4139CEFD-E45A-46AC-BA9C-C77ED036B0FD.txt
crashlog-7513B474-0E68-4B43-ACD9-4EC112E3BAAA.txt
crashlog-9590010E-D2B1-430A-84DA-94F0BA6E1232.txt
Is it possible to change a UIView background color a particular selected area?
Anyone Work on PDFKit, I draw a custom Annotation in PDFView, But I want to add action in Custom Annotation and I can't able to add Gesture in PDFAnnotation because it does not inherit from UIView, so is there any way to add Gesture in PDFAnnotation.
I am using the AVPlayer for playing the video. But my problem i.e, the the player is occurring the error. while the same url is already to play in to the Android device and Safari web browser also. If this url replaced by the other url it's working fine.This is the error.player.error==========>>>>>>>>>>Optional(Error Domain=AVFoundationErrorDomain Code=-11848 "Cannot Open" UserInfo={NSUnderlyingError=0x156d78f30 {Error Domain=NSOSStatusErrorDomain Code=-12925 "(null)"}, NSLocalizedFailureReason=The media cannot be used on this device., NSLocalizedDescription=Cannot Open})override func viewDidLoad() { super.viewDidLoad() let videoUrl = "http://telvuehls_t03007-i.akamaihd.net/hls/live/217085/T03007-calkins/playlist.m3u8" let playerItem = AVPlayerItem(URL: NSURL(string: videoUrl as String)!) let playerObj = AVPlayer(playerItem: playerItem) self.player = playerObj if playerItem.error == nil{ playerObj.play() }else{ print("player.error==========>>>>>>>>>>\(playerItem.error)") }
}