diff --git a/CHANGELOG.md b/CHANGELOG.md index 68ca9902..05fdf875 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## [Unreleased] +## [0.32.0] - 2024-11-14 ### Added @@ -13,6 +13,7 @@ ### Fixed - Error where setting `PlaybackConfig.isAutoplayEnabled = true` causes the player view creation to fail on Android +- Potential infinite stall when using `NetworkConfig.preprocessHttpRequest` and `NetworkConfig.preprocessHttpResponse` on Android ## [0.31.0] - 2024-11-07 diff --git a/android/src/main/java/com/bitmovin/player/reactnative/NetworkModule.kt b/android/src/main/java/com/bitmovin/player/reactnative/NetworkModule.kt index 4fdd5a37..4cbc854c 100644 --- a/android/src/main/java/com/bitmovin/player/reactnative/NetworkModule.kt +++ b/android/src/main/java/com/bitmovin/player/reactnative/NetworkModule.kt @@ -1,5 +1,6 @@ package com.bitmovin.player.reactnative +import android.util.Log import androidx.concurrent.futures.CallbackToFutureAdapter import androidx.concurrent.futures.CallbackToFutureAdapter.Completer import com.bitmovin.player.api.network.HttpRequest @@ -14,6 +15,7 @@ import com.bitmovin.player.reactnative.converter.toJson import com.bitmovin.player.reactnative.converter.toNetworkConfig import com.facebook.react.bridge.* import com.facebook.react.module.annotations.ReactModule +import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.Future private const val MODULE_NAME = "NetworkModule" @@ -25,8 +27,9 @@ class NetworkModule(context: ReactApplicationContext) : BitmovinBaseModule(conte * In-memory mapping from `nativeId`s to `NetworkConfig` instances. */ private val networkConfigs: Registry = mutableMapOf() - private val preprocessHttpRequestCompleters: MutableMap> = mutableMapOf() - private val preprocessHttpResponseCompleters: MutableMap> = mutableMapOf() + private val preprocessHttpRequestCompleters = ConcurrentHashMap>() + private val preprocessHttpResponseCompleters = ConcurrentHashMap>() + override fun getName() = MODULE_NAME fun getConfig(nativeId: NativeId?): NetworkConfig? = nativeId?.let { networkConfigs[it] } @@ -94,9 +97,14 @@ class NetworkModule(context: ReactApplicationContext) : BitmovinBaseModule(conte @ReactMethod fun setPreprocessedHttpRequest(requestId: String, request: ReadableMap) { - preprocessHttpRequestCompleters[requestId]?.set(request.toHttpRequest()) - preprocessHttpRequestCompleters.remove(requestId) + val completer = preprocessHttpRequestCompleters.remove(requestId) + if (completer == null) { + Log.e(MODULE_NAME, "Completer is null for requestId: $requestId, this can cause stuck network requests") + return + } + completer.set(request.toHttpRequest()) } + private fun preprocessHttpResponseFromJS( nativeId: NativeId, type: HttpRequestType, diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index bd10c783..0e6b187f 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1048,7 +1048,7 @@ PODS: - React-jsi (= 0.73.4-0) - React-logger (= 0.73.4-0) - React-perflogger (= 0.73.4-0) - - RNBitmovinPlayer (0.31.0): + - RNBitmovinPlayer (0.32.0): - BitmovinPlayer (= 3.77.0) - GoogleAds-IMA-iOS-SDK (= 3.23.0) - GoogleAds-IMA-tvOS-SDK (= 4.13.0) @@ -1301,7 +1301,7 @@ SPEC CHECKSUMS: React-runtimescheduler: 20b2202e3396589a71069d12ae9f328949c7c7b8 React-utils: 0307d396f233e47a167b5aaf045b0e4e1dc19d74 ReactCommon: 17891ca337bfa5a7263649b09f27a8c664537bf2 - RNBitmovinPlayer: a706e0f5a1a595271feda6d1fc9a9a7ff6d94104 + RNBitmovinPlayer: b05649d62740361dd1d1030ce5926e49b4a471eb RNCPicker: b18aaf30df596e9b1738e7c1f9ee55402a229dca RNScreens: b582cb834dc4133307562e930e8fa914b8c04ef2 SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 @@ -1309,4 +1309,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 11ac6cb62c1978622f6d687b574d9de3441a2680 -COCOAPODS: 1.15.2 +COCOAPODS: 1.16.2 diff --git a/integration_test/ios/Podfile.lock b/integration_test/ios/Podfile.lock index a1de6a4f..c5ee5b6b 100644 --- a/integration_test/ios/Podfile.lock +++ b/integration_test/ios/Podfile.lock @@ -1040,7 +1040,7 @@ PODS: - React-jsi (= 0.73.4-0) - React-logger (= 0.73.4-0) - React-perflogger (= 0.73.4-0) - - RNBitmovinPlayer (0.31.0): + - RNBitmovinPlayer (0.32.0): - BitmovinPlayer (= 3.77.0) - GoogleAds-IMA-iOS-SDK (= 3.23.0) - GoogleAds-IMA-tvOS-SDK (= 4.13.0) @@ -1266,10 +1266,10 @@ SPEC CHECKSUMS: React-runtimescheduler: 20b2202e3396589a71069d12ae9f328949c7c7b8 React-utils: 0307d396f233e47a167b5aaf045b0e4e1dc19d74 ReactCommon: 17891ca337bfa5a7263649b09f27a8c664537bf2 - RNBitmovinPlayer: a706e0f5a1a595271feda6d1fc9a9a7ff6d94104 + RNBitmovinPlayer: b05649d62740361dd1d1030ce5926e49b4a471eb SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Yoga: ab50eb8f7fcf1b36aad1801b5687b66b2c0aa000 PODFILE CHECKSUM: d1cd0316ec7219d421f4dfb46ced3af29fd4e932 -COCOAPODS: 1.15.2 +COCOAPODS: 1.16.2 diff --git a/package.json b/package.json index db7727e9..aadaf457 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bitmovin-player-react-native", - "version": "0.31.0", + "version": "0.32.0", "description": "Official React Native bindings for Bitmovin's mobile Player SDKs.", "main": "lib/index.js", "module": "lib/index.mjs",