Skip to content

Commit

Permalink
(tvOS) appleTV: 4K findings
Browse files Browse the repository at this point in the history
  • Loading branch information
SensehacK committed Jul 10, 2024
1 parent 21d131d commit cee8056
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 2 deletions.
6 changes: 6 additions & 0 deletions ios/tvOS/README_tvOS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@


## List

[pair_local](pair_local.md)

[ultraHD](ultraHD.md)

## References


Expand Down
11 changes: 11 additions & 0 deletions ios/tvOS/pair_local.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@



## Pairing on Wifi


go to Settings -> Remotes & Devices -> Remote App & Devices

then open Xcode -> Window -> Devices and Sims

you should be able to pair that way
58 changes: 58 additions & 0 deletions ios/tvOS/ultraHD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@


## Playback



## Error


### 4K 1st Gen Apple TV Crash

guys I think so I figured out why - just why we have 4K playback issues with 1st gen apple 4K tv.
A1842 - AppleTV6,2I went into some archives of apple newsroom and found this article where it clearly mentions that this newer gen [2nd apple tv 4K has A12 Bionic chip and it supports 4K HDR with High frame rate](https://www.apple.com/pt/newsroom/2021/04/apple-unveils-the-next-generation-of-apple-tv-4k/)So I opened up the `Olympics 4K` stream HLS file. Usually on traditional movies we have 23.7fps or 24fps. Only hobbit or handful of actual movies are shot at 60fps.
But not being prevalent to Live TV | sports streaming culture in USA, I came to know that you guys have 60hz tv vs Europe having 50hz PAL vs NTSC or something (old stuff)
& I predicted maybe `Olympics 4K` "Sports TV" content could be 60fps | hz as well. Voila! it was according to my novice understanding of HLS manifest formatting.

```ts
#EXT-X-STREAM-INF:BANDWIDTH=18104192,AUDIO="104192-mp4a.40.5",CLOSED-CAPTIONS="cc",FRAME-RATE=59.940,PROGRAM-ID=1,CODECS="hvc1.2.4.L153.90,mp4a.40.5",SUPPLEMENTAL-CODECS="dvh1.08.09/db1p",RESOLUTION=3840x2160,VIDEO-RANGE=PQ
OLYM4K_UD_02163/track-video-repid-trackId-101-tc-.m3u8
```


including the old HLS Olympics 4K stream for reference.So once in a blue moon - the error AVFoundation | AVKit gave us back is kinda true "false positive"
It said incompatibleDisplay but it should have been `incompatibleSourceFrameRateFor4K`Tl;Dr: Apple 4KTV 1st gen old hardware 2017 - mo' bit rate | frames mo' heat ==> bad bad (CPU throttling)so apple never supported it and other 4K content usually is less than 30fps.
Now I can enjoy my 4th of July ! @principal_engg @director2 



[Apple unveils the next generation of Apple TV 4K](https://www.apple.com/pt/newsroom/2021/04/apple-unveils-the-next-generation-of-apple-tv-4k/)

With A12 Bionic and the all-new Siri Remote, the best living room device gets even better. (37 kB)



P.S : sorry for late ping in the evening - just couldn't share this and close off. It all ties together why youtube was crashing on 4K videos. Because youtube videos have option for 4K at 30fps & 60fps. So my understanding is it was trying to play at higher frame rate + bitrate when network conditions are perfect -> but they had this error which was not handled by them just like PlayerPlatform had to do. Its just we were 2 - 3 years late because we never had this scenario as our content was never 4K @60fps.

References:

[apple newsroom 1st gen apple tv 4K](https://www.apple.com/newsroom/2017/09/apple-tv-4k-brings-home-the-magic-of-cinema-with-4k-and-hdr/)
no mention of high frame rate HDR or anything.

[apple HLS documentation supplemental codecs | Dolby Vision | HDR](https://developer.apple.com/documentation/http-live-streaming/hls-authoring-specification-for-apple-devices-appendixes#The-SUPPLEMENTAL-CODECS-attribute)
we were using `VIDEO-RANGE=PQ` which is `Dolby Vision`
```ts
CODECS="hvc1.2.4.L153.90,mp4a.40.5",
SUPPLEMENTAL-CODECS="dvh1.08.09/db1p",
RESOLUTION=3840x2160,
VIDEO-RANGE=PQ
```

[apple technical document for the device also mentions](https://support.apple.com/en-us/111929) so no HDR at 60fps support & we use Dolby Vision (HDR) protocol.
```markdown
### Video Formats

- H.264/HEVC SDR video up to 2160p, 60 fps, Main/Main 10 profile

- HEVC Dolby Vision (Profile 5)/HDR10 (Main 10 profile) up to 2160p
```
62 changes: 60 additions & 2 deletions ios/xcode/spm_errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Revision 37351b7ac065f11cd70c41ca7610539a82856ddf for security-spm-client-manife
Fetching from https://github.company.com/contentsecurity/security-spm-client-manifest.git (cached)
```

### missing required module ''
### missing required module

```bash
<unknown>:0: error: missing required module 'HLSObjectiveC'
Expand Down Expand Up @@ -128,4 +128,62 @@ Package.resolved file is corrupted or malformed; fix or delete the file to conti

Switching back from version 3 to version 2 worked fine for me. Maybe not committing the `Package.resolved` file should be more important to avoid these kind of flaky build failures.
Since on CI we use Xcode 15 and on my local machine I upgraded to 15.3 recently which led to upgrade of Package.resolved file with appropriate new keys like
`originHash` & `version upgrade` to 3.
`originHash` & `version upgrade` to 3.

### Build input file cannot be found

```error
Build input file cannot be found: '/Users/ksave9wrwa57/git/cloud/saf/Sources/werw/Events and Reporting/PlaySpsaan.swift'. Did you forget to declare this file as an output of a script phase or custom build rule which produces it?
```



### Credentials were rejected

```log
Showing All Messages skipping cache due to an error: Authentication failed because the credentials were rejected
```

This may happen due to one of these few reasons.

- Xcode cache is not updated. Please force quit your xcode and try again. Resolving stuff.

- Was able to clone personal repos of the account but not other organization. Turns out my firefox browser session was improperly interrupted while not completing the `allow SSO` for the independent organizations mention over here. [github token creation SSO](git/token#SSO)

- Your local system macOS keychain could have conflicting secure tokens stored for your specific domain, subdomain github flavor of version. This could happen because you have multiple git credentials, multiple git clients like Github desktop, git CLI, Gitkraken, git VSCode etc.

- Your git config `.dotFiles` found under your root personal account directory like `~` or `~/.ssh/` or your personalized config. check the file `config` for specific git configuration being setup on a global level. Sometimes you can have specific sub-directories rules or host rules. Specified over [git config global](git/config#Global)



- Make sure it has `.git` full repo URL.
```bash
https://github.com/apple/swift-argument-parser.git
```

- Update global git config from `ssh` to `https` & try again.

#### Minor Rant

So get this - remember the global git config rule. that was necessary for previous xcode since apple for some reason couldn't support GitHub fine grain tokens. -> all right I get it apple isn't on cutting edge of technology. I do `classic token` problem solved right?
No it had a problem with the `ssh` key - value pair algorithm - it can just accept the latest and greatest ED11342 xxx till last Xcode 15 beta or something 5 months back.
So had to revert to a 160 bit or something inferior encryption ssh method.Now fast forward to 2024 - we are all good and the project is great & it now fails before we upgraded the IOS dependency layer (SPM) which takes in latest helio and other stuff being bumped according to SEMVER. All good but now the SPM cache is invalidated. guess what we have been running on `cache` for past 3 - 4 months because well we were more hot on Nitro stuff innit & PP just had minor releases - cache worked fine.Now for some innate reason - apple | xcode can't take the latest token provided by us and dare u the old token is valid. On top of it xcode creates 3 more entries in keychain (password manager) to store the same tokens for maybe individual UUID projects (why - prolly a bug) which we cant even track since there isn't an open radarr bug tracking system provided by apple.
Now I thought maybe previously we had to revert on `ssh` from https. This time I'll revert back this since its `Classic -apple` yk - one day it works - other day it breaks. & Voila it freaking works again.
cue the meme


I had to disable HTTPS to SSH rewriting for Git.
`~/.gitconfig` file

```config
[url "git@github.com:"]
insteadOf = https://github.com/
```

yeah - somewhere along the lines, xcode does its own gymnastics when cloning repo via SPM vs normal other processes like carthage / cocoapods.
I reckon it hit a snag when it was not able to understand which to take when using SPM & hence previously it was just taking references from cache. Now since our old project system is intertwined with 2 build systems we have overall made it worse for xcode. But there's no documentation from apple about this behavior. This issue isn't reproducible on newer project cuz it uses SPM (first party)

Xcode seems to not like ed25519 encrypted ssh keys. Try removing those, and replace with rsa keys instead - Xcode 14.x

[Similar thread | SPM xcodebuild commands (resolve dependencies) run from AppCode do not use Xcode accounts](https://youtrack.jetbrains.com/issue/OC-21826)

0 comments on commit cee8056

Please sign in to comment.