diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f41a2027..6d1ca190c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## THE CHANGELOG +#### 3.0.1-rc.4 + - fix crash when rendering view without `channelId` property + - fix `RtcLocalView` freezes after rendering remote view + #### 3.0.1-rc.3 - fix multiple channel render bug - remove `Types` from export, you can import enum or class by `import {} from 'react-native-agora'` diff --git a/android/src/main/java/io/agora/rtc/base/RtcSurfaceView.kt b/android/src/main/java/io/agora/rtc/base/RtcSurfaceView.kt index d665d8143..59b5dbf3b 100644 --- a/android/src/main/java/io/agora/rtc/base/RtcSurfaceView.kt +++ b/android/src/main/java/io/agora/rtc/base/RtcSurfaceView.kt @@ -47,15 +47,13 @@ class RtcSurfaceView( } fun setData(engine: RtcEngine, channel: RtcChannel?, uid: Int) { - resetVideoCanvas(engine) - this.channel = if (channel != null) WeakReference(channel) else null canvas.channelId = this.channel?.get()?.channelId() canvas.uid = uid setupVideoCanvas(engine) } - private fun resetVideoCanvas(engine: RtcEngine) { + fun resetVideoCanvas(engine: RtcEngine) { val canvas = VideoCanvas(null, canvas.renderMode, canvas.channelId, canvas.uid, canvas.mirrorMode) if (canvas.uid == 0) { engine.setupLocalVideo(canvas) diff --git a/android/src/main/java/io/agora/rtc/base/RtcTextureView.kt b/android/src/main/java/io/agora/rtc/base/RtcTextureView.kt index be98e356a..1d4199d66 100644 --- a/android/src/main/java/io/agora/rtc/base/RtcTextureView.kt +++ b/android/src/main/java/io/agora/rtc/base/RtcTextureView.kt @@ -23,8 +23,6 @@ class RtcTextureView( } fun setData(engine: RtcEngine, channel: RtcChannel?, uid: Int) { - resetVideoRender(engine) - this.channel = if (channel != null) WeakReference(channel) else null this.uid = uid setupVideoRenderer(engine) @@ -35,7 +33,7 @@ class RtcTextureView( setupVideoRenderer(engine) } - private fun resetVideoRender(engine: RtcEngine) { + fun resetVideoRender(engine: RtcEngine) { if (uid == 0) { engine.setLocalVideoRenderer(null) } else { diff --git a/android/src/main/java/io/agora/rtc/react/RCTAgoraRtcSurfaceViewManager.kt b/android/src/main/java/io/agora/rtc/react/RCTAgoraRtcSurfaceViewManager.kt index 7a54a991f..af12fad81 100644 --- a/android/src/main/java/io/agora/rtc/react/RCTAgoraRtcSurfaceViewManager.kt +++ b/android/src/main/java/io/agora/rtc/react/RCTAgoraRtcSurfaceViewManager.kt @@ -20,6 +20,11 @@ class RCTAgoraRtcSurfaceViewManager : SimpleViewManager() { return RtcSurfaceView(reactContext) } + override fun onDropViewInstance(view: RtcSurfaceView) { + // getEngine()?.let { view.resetVideoCanvas(it) } + super.onDropViewInstance(view) + } + override fun getName(): String { return REACT_CLASS } diff --git a/android/src/main/java/io/agora/rtc/react/RCTAgoraRtcTextureViewManager.kt b/android/src/main/java/io/agora/rtc/react/RCTAgoraRtcTextureViewManager.kt index 60b0691e2..13e6aa3f7 100644 --- a/android/src/main/java/io/agora/rtc/react/RCTAgoraRtcTextureViewManager.kt +++ b/android/src/main/java/io/agora/rtc/react/RCTAgoraRtcTextureViewManager.kt @@ -20,6 +20,11 @@ class RCTAgoraRtcTextureViewManager : SimpleViewManager() { return RtcTextureView(reactContext) } + override fun onDropViewInstance(view: RtcTextureView) { + // getEngine()?.let { view.resetVideoRender(it) } + super.onDropViewInstance(view) + } + override fun getName(): String { return REACT_CLASS } @@ -27,9 +32,7 @@ class RCTAgoraRtcTextureViewManager : SimpleViewManager() { @ReactProp(name = "data") fun setData(view: RtcTextureView, data: ReadableMap) { val channel = data.getString("channelId")?.let { getChannel(it) } - getEngine()?.let { - view.setData(it, channel, data.getInt("uid")) - } + getEngine()?.let { view.setData(it, channel, data.getInt("uid")) } } @ReactProp(name = "mirror") diff --git a/ios/RCTAgora/Base/RtcSurfaceView.swift b/ios/RCTAgora/Base/RtcSurfaceView.swift index ed70e403a..2d20efc0c 100644 --- a/ios/RCTAgora/Base/RtcSurfaceView.swift +++ b/ios/RCTAgora/Base/RtcSurfaceView.swift @@ -19,15 +19,13 @@ class RtcSurfaceView: UIView { private weak var channel: AgoraRtcChannel? func setData(_ engine: AgoraRtcEngineKit, _ channel: AgoraRtcChannel?, _ uid: Int) { - resetVideoCanvas(engine) - self.channel = channel canvas.channelId = channel?.getId() canvas.uid = UInt(uid) setupVideoCanvas(engine) } - private func resetVideoCanvas(_ engine: AgoraRtcEngineKit) { + func resetVideoCanvas(_ engine: AgoraRtcEngineKit) { let canvas = AgoraRtcVideoCanvas() canvas.view = nil canvas.renderMode = self.canvas.renderMode diff --git a/ios/RCTAgora/React/RCTAgoraRtcSurfaceViewManager.swift b/ios/RCTAgora/React/RCTAgoraRtcSurfaceViewManager.swift index 660c8084a..80eddf16d 100644 --- a/ios/RCTAgora/React/RCTAgoraRtcSurfaceViewManager.swift +++ b/ios/RCTAgora/React/RCTAgoraRtcSurfaceViewManager.swift @@ -40,6 +40,12 @@ class RtcView: RtcSurfaceView { private var getEngine: (() -> AgoraRtcEngineKit?)? private var getChannel: ((_ channelId: String) -> AgoraRtcChannel?)? + deinit { + // if let engine = getEngine?() { + // resetVideoCanvas(engine) + // } + } + func setEngine(_ getEngine: @escaping () -> AgoraRtcEngineKit?) { self.getEngine = getEngine } diff --git a/package.json b/package.json index 4debe3cd1..6f9954476 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-agora", - "version": "3.0.1-rc.3", + "version": "3.0.1-rc.4", "description": "React Native around the Agora RTC SDKs for Android and iOS agora", "summary": "agora native sdk for react-native", "main": "lib/index.js", diff --git a/src/src/RtcRenderView.native.tsx b/src/src/RtcRenderView.native.tsx index 57a00382a..53c695415 100644 --- a/src/src/RtcRenderView.native.tsx +++ b/src/src/RtcRenderView.native.tsx @@ -69,9 +69,10 @@ const RCTRtcSurfaceView = requireNativeComponent('RCTAgoraRtcSurfaceView'); */ export class RtcSurfaceView extends Component { render() { - const {channelId, uid, ...others} = this.props + const {channelId = null, uid, ...others} = this.props return ( ) @@ -88,9 +89,10 @@ const RCTRtcTextureView = requireNativeComponent('RCTAgoraRtcTextureView'); */ export class RtcTextureView extends Component { render() { - const {channelId, uid, ...others} = this.props + const {channelId = null, uid, ...others} = this.props return ( )