TuyaInc / tuyasmart_home_ios_sdk

Tuya Smart iOS Home SDK
https://tuyainc.github.io/tuyasmart_home_ios_sdk_doc
50 stars 19 forks source link

Tuya Camera Crash on opening in Ios #72

Open nimesh1997 opened 3 years ago

nimesh1997 commented 3 years ago

Hi Tuya, I am facing a problem when ever I open a camera in Ios app crashes with the following message while camera is connecting.

Crashed: com.apple.root.default-qos 0 libobjc.A.dylib 0x1b35bc0f8 objc_msgSend + 24 1 Runner 0x100a58018 -[TuyaSmartCameraPpcsImpl connect] + 4370612248 2 Runner 0x100740b28 closure #1 in closure #1 in DoorBellViewController.viewDidLoad() + 4367371048 (:4367371048) 3 Runner 0x10074ff30 thunk for @escaping @callee_guaranteed () -> () + 4367433520 (:4367433520) 4 libdispatch.dylib 0x19e24424c _dispatch_call_block_and_release + 32 5 libdispatch.dylib 0x19e245db0 _dispatch_client_callout + 20 6 libdispatch.dylib 0x19e248ddc _dispatch_queue_override_invoke + 692 7 libdispatch.dylib 0x19e25693c _dispatch_root_queue_drain + 356 8 libdispatch.dylib 0x19e257120 _dispatch_worker_thread2 + 116 9 libsystem_pthread.dylib 0x1e9e237c8 _pthread_wqthread + 216 10 libsystem_pthread.dylib 0x1e9e2a75c start_wqthread + 8

tuyaLang commented 3 years ago

Could you please show me the podfile.lock file?

nimesh1997 commented 3 years ago

I had attached a podfile.lock content please check. Thanks.

`PODS:

DEPENDENCIES:

SPEC REPOS: trunk:

EXTERNAL SOURCES: connectivity: :path: ".symlinks/plugins/connectivity/ios" device_info: :path: ".symlinks/plugins/device_info/ios" esys_flutter_share: :path: ".symlinks/plugins/esys_flutter_share/ios" firebase_analytics: :path: ".symlinks/plugins/firebase_analytics/ios" firebase_analytics_web: :path: ".symlinks/plugins/firebase_analytics_web/ios" firebase_auth: :path: ".symlinks/plugins/firebase_auth/ios" firebase_auth_web: :path: ".symlinks/plugins/firebase_auth_web/ios" firebase_core: :path: ".symlinks/plugins/firebase_core/ios" firebase_core_web: :path: ".symlinks/plugins/firebase_core_web/ios" firebase_crashlytics: :path: ".symlinks/plugins/firebase_crashlytics/ios" firebase_database: :path: ".symlinks/plugins/firebase_database/ios" firebase_dynamic_links: :path: ".symlinks/plugins/firebase_dynamic_links/ios" firebase_messaging: :path: ".symlinks/plugins/firebase_messaging/ios" Flutter: :path: Flutter flutter_webview_plugin: :path: ".symlinks/plugins/flutter_webview_plugin/ios" fluttertoast: :path: ".symlinks/plugins/fluttertoast/ios" geocoder: :path: ".symlinks/plugins/geocoder/ios" location: :path: ".symlinks/plugins/location/ios" location_web: :path: ".symlinks/plugins/location_web/ios" package_info: :path: ".symlinks/plugins/package_info/ios" path_provider: :path: ".symlinks/plugins/path_provider/ios" path_provider_linux: :path: ".symlinks/plugins/path_provider_linux/ios" path_provider_macos: :path: ".symlinks/plugins/path_provider_macos/ios" path_provider_windows: :path: ".symlinks/plugins/path_provider_windows/ios" printing: :path: ".symlinks/plugins/printing/ios" share: :path: ".symlinks/plugins/share/ios" shared_preferences: :path: ".symlinks/plugins/shared_preferences/ios" sqflite: :path: ".symlinks/plugins/sqflite/ios" url_launcher: :path: ".symlinks/plugins/url_launcher/ios" video_player: :path: ".symlinks/plugins/video_player/ios" video_player_web: :path: ".symlinks/plugins/video_player_web/ios" wakelock: :path: ".symlinks/plugins/wakelock/ios" webview_flutter: :path: ".symlinks/plugins/webview_flutter/ios"

SPEC CHECKSUMS: CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 connectivity: c72716e202a1225ec4810740d5cb56b8ae3bf4cc device_info: d7d233b645a32c40dfdc212de5cf646ca482f175 esys_flutter_share: 403498dab005b36ce1f8d7aff377e81f0621b0b4 Firebase: 8db6f2d1b2c5e2984efba4949a145875a8f65fe5 firebase_analytics: 4538549a97ab7ef715588ec23cb3b555455169e7 firebase_analytics_web: 7d539061ea4af07563a0e21044af89cab70efec0 firebase_auth: 240419f6b00dea39c60a2a9c4379c16c4a4b02fb firebase_auth_web: 0955c07bcc06e84af76b9d4e32e6f31518f2d7de firebase_core: 350ba329d1641211bc6183a3236893cafdacfea7 firebase_core_web: d501d8b946b60c8af265428ce483b0fff5ad52d1 firebase_crashlytics: ebe0a8b60ac43115a4c80db5c63a00bbdeaf1770 firebase_database: bd51dc26c060f6e27a1326bc8c1ba283cd63c987 firebase_dynamic_links: 6aa278fc5e6e8cca17d5aa4c7aa46283f2b94749 firebase_messaging: 21344b3b3a7d9d325d63a70e3750c0c798fe1e03 FirebaseAnalytics: 5dd088bd2e67bb9d13dbf792d1164ceaf3052193 FirebaseAuth: c92d49ada7948d1a23466e3db17bc4c2039dddc3 FirebaseCore: d889d9e12535b7f36ac8bfbf1713a0836a3012cd FirebaseCoreDiagnostics: 770ac5958e1372ce67959ae4b4f31d8e127c3ac1 FirebaseCrashlytics: 1a747c9cc084a24dc6d9511c991db1cd078154eb FirebaseDatabase: 13a865a4b85897462b930eb683bda8f52583713f FirebaseDynamicLinks: 6eac37d86910382eafb6315d952cc44c9e176094 FirebaseInstallations: 466c7b4d1f58fe16707693091da253726a731ed2 FirebaseInstanceID: bd3ffc24367f901a43c063b36c640b345a4a5dd1 FirebaseMessaging: 5eca4ef173de76253352511aafef774caa1cba2a Flutter: 0e3d915762c693b495b44d77113d4970485de6ec flutter_webview_plugin: ed9e8a6a96baf0c867e90e1bce2673913eeac694 fluttertoast: b644586ef3b16f67fae9a1f8754cef6b2d6b634b FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a geocoder: 3cfab70531a0b367e917bafe82df4c30f6d4c45a GoogleAppMeasurement: 966e88df9d19c15715137bb2ddaf52373f111436 GoogleDataTransport: f56af7caa4ed338dc8e138a5d7c5973e66440833 GoogleUtilities: 7f2f5a07f888cdb145101d6042bc4422f57e70b3 GTMSessionFetcher: b3503b20a988c4e20cc189aa798fd18220133f52 leveldb-library: 55d93ee664b4007aac644a782d11da33fba316f7 location: 3a2eed4dd2fab25e7b7baf2a9efefe82b512d740 location_web: b94e7433cfe28c0f7c8923c2ee482824b32e55a7 MQTTClient: 902c7bcac1501595f3d0b15178c7205b40331fb0 nanopb: 59317e09cf1f1a0af72f12af412d54edf52603fc OpenSSL-Universal: ff34003318d5e1163e9529b08470708e389ffcdd package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62 path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c path_provider_linux: 4d630dc393e1f20364f3e3b4a2ff41d9674a84e4 path_provider_macos: f760a3c5b04357c380e2fddb6f9db6f3015897e0 path_provider_windows: a2b81600c677ac1959367280991971cb9a1edb3b printing: 5ec249946ebbd51cead5ed9b0b48113bb5141bcf PromisesObjC: 3113f7f76903778cf4a0586bd1ab89329a0b7b97 Protobuf: 0cde852566359049847168e51bd1c690e0f70056 Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96 share: 7d22fe8baedfe93aefd864bf0b73f29711fbb0a3 shared_preferences: 1feebfa37bb57264736e16865e7ffae7fc99b523 sqflite: 4001a31ff81d210346b500c55b17f4d6c7589dd0 TuyaCameraSDK: 80ab38116c33e5f3139ca06b1ed685a398d03f08 TuyaSmartActivatorKit: 161d56db2e68fd1fad66820af0bffc15e70f5ae0 TuyaSmartBaseKit: 34ecdf83e4204bcc61bf399f7faa8b25ec2e1d48 TuyaSmartBLEKit: 1448cf65c11c850cfd7041d354987a3059498ab3 TuyaSmartBLEMeshKit: e99f978c07573fde2f2139f394ccdd99f3ab9488 TuyaSmartCameraBase: 0c6ea4b08c07c0ffd37d35751875a9dcde347659 TuyaSmartCameraKit: 601f1cd3581414d89ceb1c854bfe4db9131e1055 TuyaSmartCameraM: 235d6baeab3d57cffab0316ababa7c3b39407811 TuyaSmartDeviceCoreKit: 908aedc49bde250755116071ed9adf2dc7c87de2 TuyaSmartDeviceKit: c7801e3d1ae27822d5391e7fdc8c0d7eaa3deea9 TuyaSmartFeedbackKit: 4afe1fb31ab165f5b0f3418405c653b74a751707 TuyaSmartHomeKit: 1b2ab426e111a7b60a03e27636acdd75c0e2fde7 TuyaSmartMessageKit: 6302d0dc1111948c20a96f38e44d69429014108b TuyaSmartMQTTChannelKit: 096c40a5be0e3953211453e7c6e7ea621512e261 TuyaSmartQUIC: 5bb81563fedf5b739ac50a5abbf42ec807cfb64b TuyaSmartSceneKit: 4c98f3f7e5c2a8418139e3a356bba5cf61d87599 TuyaSmartSocketChannelKit: 094737c579ed90d3d4f9a9a58455aed57d2cd666 TuyaSmartTimerKit: 62cc6ee5bcaec18d1c149b98639e6dffc79fa8f5 TuyaSmartUtil: e657ec568b2df6ea578554870962528c47ee200d TYBluetooth: 0741669a99673b1de97365fb7584eaee75db2bdd TYEncryptImage: b7dd13b66c9d54b8fc7ce68c6a04042c169784cf url_launcher: 0067ddb8f10d36786672aa0722a21717dba3a298 video_player: 9cc823b1d9da7e8427ee591e8438bfbcde500e6e video_player_web: da8cadb8274ed4f8dbee8d7171b420dedd437ce7 wakelock: 0d4a70faf8950410735e3f61fb15d517c8a6efc4 webview_flutter: d2b4d6c66968ad042ad94cbb791f5b72b4678a96 YYModel: 2a7fdd96aaa4b86a824e26d0c517de8928c04b30

PODFILE CHECKSUM: 65a81d61364f3fb73c378b87cbf46cb0e3d4dd57

COCOAPODS: 1.10.0 `

tuyaLang commented 3 years ago

Can you send me the code for creating the camera and connecting?

nimesh1997 commented 3 years ago

I had attached the code below of camera initialisation,connecting and startPreview. Thanks

Code below:

//maintain TuyaSmartCameraType instance. var doorBellCamera: TuyaSmartCameraType? = nil

inside viewDidLoad override func viewDidLoad() { super.viewDidLoad() guard let device: TuyaSmartDevice = TuyaSmartDevice(deviceId: doorBellDeviceId) else{ print("tuya smartDevice is null initialisation failed") return }

           if device != nil {

           let p2pType = device.deviceModel.skills["p2pType"]
               let postData : NSDictionary = [
                   "devId": doorBellDeviceId
               ]

           TuyaSmartRequest().request(withApiName: "tuya.m.rtc.session.init",
                                                   postData: postData as? [AnyHashable : Any],
                                                   version: "1.0",
                                                   success:{ result in
                                                       guard let responder = result as? [AnyHashable:Any] else {
                                                           return;
                                                       }
                                                       DispatchQueue.global().async {
                                                           let config = TuyaSmartCameraFactory.ipcConfig(withUid: TuyaSmartUser.sharedInstance().uid, localKey: device.deviceModel.localKey, configData: responder)
                                                        self.doorBellCamera = TuyaSmartCameraFactory.camera(withP2PType: p2pType, config: config, delegate: self)
                                                        device.awake(success: nil, failure: nil)
                                                        self.doorBellCamera?.connect()

                                                       }

                                                   },
                                                   failure: { (error) in
                                                       if let e = error {
                                                           doorBellResult?(FlutterError(code: "getCameraConfigurations failure \(String(describing: error))", message: "getDoorbellConfigurations failure called ", details: nil))
                                                       }
                                                   })
           }

}

override func viewDidAppear(_ animated: Bool) { if(self.isConnected){ buildVideoView() } }

 func cameraDidConnected(_ camera: TuyaSmartCameraType!) {
    //update flag here
    self.isConnected = true
    //start live video
    doorBellCamera?.startPreview()
}

func cameraDidBeginPreview(_ camera: TuyaSmartCameraType!) {
    buildVideoView()
    doorBellCamera?.autoRender = true
}
nimesh1997 commented 3 years ago

Hi, Can you please tell me why this error occurs and how to resolve this? Thanks.