Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ on:
workflow_dispatch:
inputs:
version:
description: 'New SDK version (e.g. 5.1.38 or 5.2.0-beta1)'
description: "New SDK version (e.g. 5.1.38 or 5.2.0-beta1)"
type: string
required: true
base_branch:
description: 'Target branch for the PR (e.g. main for regular releases, 5.4-main for 5.4.x releases)'
description: "Target branch for the PR (e.g. main for regular releases, 5.4-main for 5.4.x releases)"
type: string
required: false
default: 'main'
default: "main"

permissions:
contents: write
Expand Down Expand Up @@ -64,14 +64,17 @@ jobs:
fi

- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
fetch-depth: 0 # Ensure full history for git log
fetch-tags: true
fetch-depth: 0 # Ensure full history for git log
fetch-tags: true

- name: Setup Git User
uses: OneSignal/sdk-actions/.github/actions/setup-git-user@main

- name: Create release branch from base
run: |

if git ls-remote --exit-code --heads origin "$BRANCH"; then
echo "Deleting remote branch $BRANCH"
git push origin --delete "$BRANCH"
Expand All @@ -87,9 +90,6 @@ jobs:

- name: Commit and Push changes
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"

git commit -am "chore: bump SDK_VERSION to $VERSION"
git push origin "$BRANCH"

Expand Down Expand Up @@ -183,4 +183,4 @@ jobs:
--title "Release SDK v$VERSION" \
--body-file pr_body.md \
--head "$BRANCH" \
--base "$BASE_BRANCH"
--base "$BASE_BRANCH"
13 changes: 12 additions & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:

permissions:
contents: write
pull-requests: read
pull-requests: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -24,6 +24,8 @@ concurrency:
jobs:
publish:
runs-on: ubuntu-latest
outputs:
sdk_version: ${{ steps.extract_version.outputs.version }}

env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
Expand Down Expand Up @@ -80,6 +82,7 @@ jobs:
run: |
VERSION=$(grep '^SDK_VERSION=' OneSignalSDK/gradle.properties | cut -d '=' -f2)
echo "SDK_VERSION=$VERSION" >> $GITHUB_ENV
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Resolved version: $VERSION"

- name: Assemble Release
Expand Down Expand Up @@ -174,3 +177,11 @@ jobs:
--title "$VERSION" \
--notes-file release_notes.md \
$PRERELEASE

wrapper_prs:
needs: publish
uses: OneSignal/sdk-actions/.github/workflows/create-wrapper-prs.yml@main
secrets:
GH_PUSH_TOKEN: ${{ secrets.GH_PUSH_TOKEN }}
with:
android_version: ${{ needs.publish.outputs.sdk_version }}
2 changes: 1 addition & 1 deletion OneSignalSDK/onesignal/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ android {
}
testOptions {
unitTests.all {
maxParallelForks 1
maxParallelForks Math.max(2, Runtime.runtime.availableProcessors().intdiv(2))
maxHeapSize '3072m'
jvmArgs '-XX:MaxMetaspaceSize=256m', '-XX:+UseG1GC', '-XX:+UseStringDeduplication'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ object AndroidUtils {
return appVersion?.toString()
}

// return Build.VERSION.SDK_INT; can be mocked to test specific functionalities under different SDK levels
val androidSDKInt: Int = Build.VERSION.SDK_INT

fun getManifestMeta(
context: Context,
metaName: String?,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ import java.util.concurrent.atomic.AtomicInteger
* - Small bounded queues (10 tasks) to prevent memory bloat
* - Reduced context switching overhead
* - Efficient thread management with controlled resource usage
*
* Made public to allow mocking in tests via IOMockHelper.
*/
internal object OneSignalDispatchers {
object OneSignalDispatchers {
// Optimized pool sizes based on CPU cores and workload analysis
private const val IO_CORE_POOL_SIZE = 2 // Increased for better concurrency
private const val IO_MAX_POOL_SIZE = 3 // Increased for better concurrency
Expand All @@ -35,7 +37,7 @@ internal object OneSignalDispatchers {
private const val KEEP_ALIVE_TIME_SECONDS =
30L // Keep threads alive longer to reduce recreation
private const val QUEUE_CAPACITY =
10 // Small queue that allows up to 10 tasks to wait in queue when all threads are busy
200 // Increased to handle more queued operations during init, while still preventing memory bloat
internal const val BASE_THREAD_NAME = "OneSignal" // Base thread name prefix
private const val IO_THREAD_NAME_PREFIX =
"$BASE_THREAD_NAME-IO" // Thread name prefix for I/O operations
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.onesignal.core.internal.operations.impl

import com.onesignal.common.threading.WaiterWithValue
import com.onesignal.common.threading.suspendifyOnIO
import com.onesignal.core.internal.config.ConfigModelStore
import com.onesignal.core.internal.operations.ExecutionResult
import com.onesignal.core.internal.operations.GroupComparisonType
Expand All @@ -14,7 +13,10 @@ import com.onesignal.debug.LogLevel
import com.onesignal.debug.internal.logging.Logging
import com.onesignal.user.internal.operations.impl.states.NewRecordsState
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.newSingleThreadContext
import kotlinx.coroutines.withTimeoutOrNull
import java.util.UUID
import kotlin.math.max
Expand Down Expand Up @@ -43,6 +45,14 @@ internal class OperationRepo(
val previousWaitedTime: Long = 0,
)

// The order of operation execution is critical to this OperationRepo
// logic, all processing must be done on same thread to ensure this.
// - This result of not following this is flaky tests, which inturn could
// result in bugs in production.
private val scope by lazy {
CoroutineScope(newSingleThreadContext(name = "OSOperationRepoScope"))
}

private val executorsMap: Map<String, IOperationExecutor>
internal val queue = mutableListOf<OperationQueueItem>()
private val waiter = WaiterWithValue<LoopWaiterMessage>()
Expand Down Expand Up @@ -92,7 +102,7 @@ internal class OperationRepo(

override fun start() {
paused = false
suspendifyOnIO {
scope.launch {
// load saved operations first then start processing the queue to ensure correct operation order
loadSavedOperations()
processQueueForever()
Expand All @@ -113,8 +123,7 @@ internal class OperationRepo(
Logging.log(LogLevel.DEBUG, "OperationRepo.enqueue(operation: $operation, flush: $flush)")

operation.id = UUID.randomUUID().toString()
// Use suspendifyOnIO to ensure non-blocking behavior for main thread
suspendifyOnIO {
scope.launch {
internalEnqueue(OperationQueueItem(operation, bucket = enqueueIntoBucket), flush, true)
}
}
Expand All @@ -127,7 +136,9 @@ internal class OperationRepo(

operation.id = UUID.randomUUID().toString()
val waiter = WaiterWithValue<Boolean>()
internalEnqueue(OperationQueueItem(operation, waiter, bucket = enqueueIntoBucket), flush, true)
scope.launch {
internalEnqueue(OperationQueueItem(operation, waiter, bucket = enqueueIntoBucket), flush, true)
}
return waiter.waitForWake()
}

Expand Down
Loading
Loading