Show common user interface elements from Apple TV in your native app using TVUIKit.

Posts under TVUIKit tag

5 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

[tvOS 18][SwiftUI] Severe ScrollView Lag after Update
Hello, I've upgraded both of my Apple TVs to tvOS 18. Since then, my app developed with SwiftUI has become almost unusable due to severe lag, particularly when scrolling in a LazyVStack. On the A1625 (Apple TV HD), the lag can last up to 20 seconds, while on the A2843 (Apple TV 4K, 3rd generation, Wi-Fi + Ethernet), it’s about one second. I can consistently reproduce the issue with this minimal example: @main struct MyApp: App { var body: some Scene { WindowGroup { ScrollView { LazyVStack { ForEach(0..<1000) { nb in Button("Item \(nb)") {} } } } } } } Using Instruments, I found that the hang is related to this call: 389.00 ms 71,4 % 6.00 ms +[_UIFocusRegionEvaluator __regionsByEvaluatingOcclusionsForBaseRegions:occludingRegions:baseRegionsCanOccludeEachOther:inSnapshot:] Unfortunately, I can't attach the Instruments trace directly here, but you can download it from this link: https://drive.google.com/file/d/1sEIwXhr7_ajjRHZevCIW6jNOlPjaeU6L/view?usp=sharing Important notes: The same screen, when written in UIKit, runs smoothly on both devices. After performing a factory reset on the older device, the performance issue disappeared. However, as you can imagine, I’m already receiving complaints from users who are understandably unwilling to reset their devices. Does anyone know of a workaround until this is addressed by Apple?
3
1
492
Oct ’24
UICollectionView can't keep the focused row stick to the top
I'm creating a Netflix like app on tvOS, here is my compositional layout that I use with my collectionView. private func createLayout() -> UICollectionViewCompositionalLayout { return UICollectionViewCompositionalLayout { (section, _) -> NSCollectionLayoutSection? in // item let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .fractionalHeight(1.0)) let item = NSCollectionLayoutItem(layoutSize: itemSize) item.contentInsets = NSDirectionalEdgeInsets(top: 0, leading: 10, bottom: 0, trailing: 10) // group let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1/5), heightDimension: .estimated(350)) let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item]) // section let section = NSCollectionLayoutSection(group: group) section.orthogonalScrollingBehavior = .groupPaging let headerSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .estimated(UIFont(name: "MyFont", size: 36)!.lineHeight)) let sectionHeader = NSCollectionLayoutBoundarySupplementaryItem( layoutSize: headerSize, elementKind: "SectionHeader", alignment: .top) section.boundarySupplementaryItems = [sectionHeader] section.contentInsets = NSDirectionalEdgeInsets(top: 0, leading: 20, bottom: 30, trailing: 0) return section } } So: My collection view is composed by several row (that are the sections). Each section is composed by groups containing 1 item each. Each section can be scrolled horizontally. And you can scroll vertically to move from a section to an other. I'm expecting to have the following behavior when scrolling: Horizontal scrolling: Before focus shifts -------------------------- | vA vB vC vD vE | | [v1] v2 v3 v4 v5 | | vU vW vX vY vZ | -------------------------- After focus shifts -------------------------- | vA vB vC vD vE | | [v2] v3 v4 v5 v6 | | vU vW vX vY vZ | -------------------------- Vertical scroll: Before focus shifts -------------------------- | [vA] vB vC vD vE | | v1 v2 v3 v4 v5 | | vU vW vX vY vZ | -------------------------- After focus shifts -------------------------- | [v1] v2 v3 v4 v5 | | vU vW vX vY vZ | | vF vG vH vI vJ | -------------------------- Thanks to section.orthogonalScrollingBehavior = .groupPaging the horizontal scrolling is working as expected. (I've put 1 item per group to achieve this) But I'm going crazy with the vertical scroll, I'm not able to achieve it as expected, the focused section still centered verticaly on the screen ! What I'm getting: Before focus shifts -------------------------- | [vA] vB vC vD vE | | v1 v2 v3 v4 v5 | | vU vW vX vY vZ | -------------------------- After focus shifts -------------------------- | vA vB vC vD vE | | [v1] v2 v3 v4 v5 | | vU vW vX vY vZ | -------------------------- After an other focus shifts -------------------------- | v1 v2 v3 v4 v5 | | [vU] vW vX vY vZ | | vF vG vH vI vJ | -------------------------- I've tried to play with the didUpdateFocusIn function without success func collectionView(_ collectionView: UICollectionView, didUpdateFocusIn context: UICollectionViewFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) { if let nextFocusedItemIndexPath = context.nextFocusedIndexPath { let section = nextFocusedItemIndexPath.section let sectionIndexPath = IndexPath(item: 0, section: section) collectionView.scrollToItem(at: sectionIndexPath, at: .top, animated: true) } } The collectionview is behaving strangely when using the didUpdateFocusIn function and I feel it's not the good way to perform what I'm expecting... I've also try to play with the scrollViewWillEndDragging function without success func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: } Everything that I tried looks like a hack and I can't believe Apple has not plan something for this use case, which is in my sense a common use case....
1
0
441
Aug ’24
AVPlayerViewController (AppleTV) - Dolby (multi-channel audio) visualisation
We noticed that AVPlayerViewController does not always show the "Multi-channel" label in the audio setting in the player when playing a video asset with surround sound as an audio track. (see image) We only serve in the HLS master manifest a multichannel audio track, like this #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio_0",CHANNELS="6",NAME="Surround",LANGUAGE.... Different tvOS versions will give us different outcomes on whether or not the "multi-channel" label is shown DOES NOT SHOW (the label Multi-channel will not show) Model A1842 (tvOS v 17.5.1) Model A1625 (tvOS v 16.6) DOES SHOW (see image) Model A1625 (tvOS v 15.6) This gives us the impression that the label being shown depends on tvOS version.. Any reason why? This is an ideal way for the user to see that the audio track has surround..
0
1
487
Jul ’24
Getting Swift_header compilation error for tvOS
I have a tvOS project contains an App target and 3 static libraries: EntryPoint – Static library that contains main , AppDelegate and SceneDelegate Experience – Static library containing my UI elements AppTarget – executable built using above two libraries I have a class "SelectionTable" which subclasses UITableView in Experience target : import UIKit class SelectionTable : UITableView { private var vDataSrc:[String]! func SetDataSrc (_ pDataSrc:[String]) { self.vDataSrc = pDataSrc } func UpdateDataSrc (_ pStringList:[String]) { self.vDataSrc += pStringList } func GetDataSrc () -> [String] { return self.vDataSrc } } I am not using this class anywhere and still i am getting these errors when i build my AppTarget: Cannot find interface declaration for 'UITableView', superclass of 'SelectionTable' Expected a type These above error are coming in generated header file "Experience-Swift.h". This file is auto-generated by compiler. I am not using @objc anywhere in the code, But still the Target-Swift.h file has the below lines: SWIFT_CLASS("_TtC10Experience22SelectionTable") @interface SelectionTable : UITableView - (nonnull instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style OBJC_DESIGNATED_INITIALIZER; - (nullable instancetype)initWithCoder:(NSCoder * _Nonnull)coder OBJC_DESIGNATED_INITIALIZER; @end When i am marking above class as Private , this error goes away . And also , if i am defining SelectionTable class in EntryPoint library , this error does not occur . I am using similar model for an iOS project also and there i am not facing this issue. I am using :- Swift version : Swift 5.9.2 XCode version : 15.2
0
2
728
Feb ’24
TVOS 17 Alert tintColor Issue
The alertController.view.tintColor = .yellow statement does not seem to take effect in TVOS 17 when creating alerts. Interestingly, when using the same alert code on TVOS 16, the specified color is applied successfully. I'm seeking assistance in resolving this discrepancy and would appreciate any guidance or solutions you can provide. I could understand that the Alert design aswell is modified which is not mentioned in the release notes of TVOS 17. Please help me out here. TVOS 17: TVOS 16:
0
0
663
Dec ’23