Skip to content

Commit

Permalink
Merge pull request #107 from superwall/develop
Browse files Browse the repository at this point in the history
1.1.4
  • Loading branch information
yusuftor authored May 9, 2024
2 parents b80c042 + 2777268 commit a934038
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

The changelog for `Superwall`. Also see the [releases](https://github.com/superwall/Superwall-Android/releases) on GitHub.

## 1.1.4

### Fixes

- Fixes thread safety crash when multiple threads attempted to initialize the `JavaScriptSandbox`
internally.

## 1.1.3

### Enhancements
Expand Down
2 changes: 1 addition & 1 deletion superwall/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ plugins {
id("signing")
}

version = "1.1.3"
version = "1.1.4"

android {
compileSdk = 33
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.guava.await
import kotlinx.coroutines.launch
import kotlinx.coroutines.newSingleThreadContext
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.withContext
import org.json.JSONObject

Expand All @@ -38,6 +40,7 @@ class ExpressionEvaluator(
private val factory: RuleAttributesFactory
): ExpressionEvaluating {
private val singleThreadContext = newSingleThreadContext(name = "ExpressionEvaluator")
private val mutex = Mutex()

companion object {
private var jsSandbox: JavaScriptSandbox? = null
Expand All @@ -47,8 +50,10 @@ class ExpressionEvaluator(
init {
if (JavaScriptSandbox.isSupported()) {
CoroutineScope(singleThreadContext).launch {
if (jsSandbox == null) {
jsSandbox = JavaScriptSandbox.createConnectedInstanceAsync(context).await()
mutex.withLock {
if (jsSandbox == null) {
jsSandbox = JavaScriptSandbox.createConnectedInstanceAsync(context).await()
}
}
}
} else {
Expand Down

0 comments on commit a934038

Please sign in to comment.