问题
When I do this code, the FbMediaView is like loading the ads video on the main thread but it's not freezing when displaying an image. I don't understand why ?
let nativeAd = self.adsManager.nextNativeAd()
let cell : AdHomeCell? = self.collectionView!.dequeueReusableCellWithReuseIdentifier("AdHomeCell", forIndexPath: indexPath) as? AdHomeCell
cell?.createForAd(nativeAd)
nativeAd?.registerViewForInteraction(cell!, withViewController: self)
return cell
I have the latest Facebook SDK (4.8.0)
回答1:
The Audience Network iOS SDK uses AVFoundation internally to play video ads. Initializing an AVAsset does a lot of work on the main thread. The main thread handles all UI updates on iOS, so this results in visible pausing, particularly when loading multiple video ads. There is no way to offload that work to a different thread without using private API.
We're aware of the performance impact. We're deploying some short term marginal improvements in v4.9, and we're working on a long term fix. Right now, it is not recommended to use video ads in certain apps that need high levels of scrolling performance.
(I'm a software engineer on Audience Network, and develop the iOS SDK.)
来源:https://stackoverflow.com/questions/34677164/fbaudiencenetwork-fbmediaview-freeze-ui-when-displaying-video