我仅在iOS 11.2中面临以下代码中的崩溃。我使用的是swift 4.0。我试图调试几个小时来重现崩溃,但无法成功。这是代码
func prepareNewConnection(conn:String) -> RTCPeerConnection {
let uuid = UIDevice.current.identifierForVendor?.uuidString
localAudioTrack = peerConnectionFactory.audioTrack(withTrackId: uuid!)
mediaStream = peerConnectionFactory.mediaStream(withStreamId: LOCAL_MEDIA_STREAM_ID)
if(localAudioTrack != nil && mediaStream != nil)
{
mediaStream.addAudioTrack(localAudioTrack!) //Crash on this line
}
let pc = peerConnectionFactory.peerConnection(with: rtcConfig, constraints: mediaConstraints, delegate: self)
if(mediaStream != nil)
{
pc.add(mediaStream)
}
return pc;
}
以下是崩解报告。
https://www.playframework.com/documentation/2.6.x/ScalaAsync#Creating-non-blocking-actions
我将非常感谢任何帮助。
答案 0 :(得分:0)
请避免安全展开,如果让..
func prepareNewConnection(conn:String) -> RTCPeerConnection {
if let uuid = UIDevice.current.identifierForVendor?.uuidString {
localAudioTrack = peerConnectionFactory.audioTrack(withTrackId: uuid) //removed safely Unwrapping
mediaStream = peerConnectionFactory.mediaStream(withStreamId: LOCAL_MEDIA_STREAM_ID)
let pc = peerConnectionFactory.peerConnection(with: rtcConfig,constraints: mediaConstraints, delegate: self)
if(localAudioTrack != nil && mediaStream != nil)
{
mediaStream.addAudioTrack(localAudioTrack)
pc.add(mediaStream)
}
}
return pc
}