# Bugsee Unity SDK Bug reporting, crash capture, and session replay for Unity games and apps on iOS and Android. ## Requirements - Unity **2021.3** or newer - iOS builds: Xcode with Swift Package Manager support; **iOS 15+** (Bugsee 7.1.0); `bugsee-cli` on the PATH for archive-time symbol upload - Android builds: nothing to set up (no EDM4U, no custom Gradle templates; the build needs Maven Central, which Unity's Gradle project already lists); `bugsee-cli` on the PATH for Editor symbol upload ## Installation Package Manager → **+** → **Add package from git URL**: ``` https://github.com/bugsee/bugsee-unity.git ``` That is all: there is no scoped registry to add and no dependency-resolve step. On Android, every build declares `com.bugsee:bugsee-android` and `com.bugsee:bugsee-android-ndk` in the generated `unityLibrary/build.gradle` (and adds `mavenCentral()` to the project repositories if Unity's Gradle layout lacks it). Projects that use EDM4U for other SDKs are unaffected. If the project already declares the Bugsee Android SDK itself (EDM4U, a custom `mainTemplate.gradle`, a local AAR), that declaration wins: nothing is added next to it, and the build log warns if its version differs from the package's pin or the NDK artifact is missing. ## Launch ```csharp #if UNITY_ANDROID var options = new AndroidLaunchOptions { DetectAndReportCrash = true, // native process death (Java + NDK) CaptureManagedExceptions = true, // Unity ExceptionPipeline (default on if omitted) DetectAndReportHang = true, DetectAndReportExitNotResponding = true, // ApplicationExitInfo ANR DetectAndReportExitLowMemory = true, // OOM / low memory exits }; Bugsee.Launch(appToken, options); #elif UNITY_IOS var options = new IOSLaunchOptions { DetectAndReportCrash = true, CaptureManagedExceptions = true, DetectAndReportHang = true, }; Bugsee.Launch(appToken, options); #endif ``` `CaptureManagedExceptions` is independent of `DetectAndReportCrash`. Omit it to keep the default (enabled). `CaptureUnobservedTaskExceptions` (default enabled, needs `CaptureManagedExceptions`) controls whether `TaskScheduler.UnobservedTaskException` is reported; set it to `false` for apps whose fire-and-forget tasks fault on purpose. A `Relaunch` applies a changed value. Unity raises that event only after the faulted `Task` is garbage-collected, so the handled error arrives late and at a time you do not control. ### iOS-only launch options `IOSLaunchOptions` has typed properties for the iOS SDK 7.0.0 options that Android has no counterpart for. They are iOS only: on Android the wrapper drops them before launch (`OptionPlatformGate`), so setting one has no effect there. The Android SDK would drop an unknown key too, but the wrapper does not depend on that. The same keys are available as `Options` constants for `OptionsBuilder` and `SetCustomOption`, with the same gating (`OptionsBuilder` and `SetCustomOption` do no range checks; `OptionsBuilder` also has `SetCrashHandlerType`, `SetDataEncryption` and `SetReportingUIStyle`; its `SetCrashSignals` is not iOS-only, it reaches both platforms). The iOS SDK drops a host option equal to its default from the host launch options; `GetLaunchOptions` always shows the effective value. | Property | Key suffix | Type, default | |---|---|---| | `CrashHandlerType` | `capture.crash-handler-type` | `CrashHandlerType`, `MachAndBSD` | | `CaptureOnDeviceSymbolication` | `capture.on-device-symbolication` | bool, false | | `CrashSwiftAsyncStackTraces` | `detect.crash.swift_async_stacktraces` | bool, true | | `CrashFillEmptyExceptionStacks` | `detect.crash.fill_empty_exception_stacks` | bool, false (can change crash grouping) | | `CaptureWebSocket` | `capture.websocket` | bool, true | | `CaptureAVPlayer` | `capture.avplayer` | bool, false. Native AVPlayerLayer only, not Unity's VideoPlayer | | `CaptureSampleBufferDisplayLayer` | `capture.sample-buffer-display-layer` | bool, false | | `CaptureCameraPreview` | `capture.camera-preview` | bool, false. Native AVCaptureVideoPreviewLayer only, not Unity's WebCamTexture. Privacy: records what the camera sees | | `CaptureBluetoothStatus` | `capture.bluetooth-status` | bool, false. Reports a status only if the app itself asked for and got Bluetooth permission (the SDK never asks); otherwise unknown or unauthorized | | `CaptureDiskSpace` | `capture.disk-space` | bool, false. Apple's reason for the API forbids sending it off the device: use it in development builds | | `CaptureDeviceNetworkNames` | `capture.device-network-names` | bool, false. Sends the device name and Wi-Fi network name (personal data; redacted otherwise); the Wi-Fi name also needs an Apple entitlement and location permission | | `CaptureVideoPrivacyBlur` | `capture.video.privacy-blur` | bool, true. Off, the video freezes for a transition instead of blurring it | | `CaptureVideoMinFrameRate`, `CaptureVideoMaxFrameRate` | `capture.video.min-frame-rate`, `capture.video.max-frame-rate` | int fps, the SDK clamps to 0..30; a minimum needs a maximum at or above it (otherwise it is dropped); 0 = derived from `FrameRate`. Default 0 | | `DataEncryption` | `config.data-encryption` | `DataEncryptionMode` (`None`, `OnDevice`, `EndToEnd`), `None`. `EndToEnd` leaves some features out, such as the video preview. iOS SDK 7.0.0 no longer declares the key or the enum in its public headers, but its options manifest still lists `config.data-encryption` (not hidden) and its binary still has `initializeDataEncryption` and `setDataEncryption:`. Measured on an iPhone XS with 7.0.0: the key is accepted and `GetLaunchOptions` reports it (`OnDevice` sent, `OnDevice` read back), and a launch with `OnDevice` (the `minimal` preset) uploads a report that the dashboard shows normally. Not verified: that the data is actually encrypted at rest, or that `EndToEnd` works | | `BuildTarget`, `BuildType` | `config.build-target`, `config.build-type` | string, none | | `ReportingUIStyle` | `reporting.ui.style` | `ReportingUIStyle` (`Light`, `Dusk`, `BasedOnStatusBar`, `System`), `System` | **Null references and `CrashSignals` (iOS, Android).** The iOS SDK's header warns that .NET hosts turn `SIGSEGV`/`SIGBUS` into `NullReferenceException` and that those signals should then be left out. That applies to Mono/.NET runtimes that raise the exception from a signal handler; Unity's IL2CPP player, the only scripting backend on iOS, does not: it compiles an explicit null check before each access, so a null reference (caught or not) is an ordinary managed exception and never reaches the crash reporter as a signal. Verified on an iPhone XS (iOS, Unity 2022.3 IL2CPP, Release build): a caught `NullReferenceException`, one thrown on a coroutine and one in a thread-pool task produced no crash report and no `RelaunchedAfterCrash` on the next launch, and the process kept running. Keep the default (`CrashSignals.Default`, which reports `Segv` and `Bus`): a real fault (a bad native pointer, or a null access in code compiled with IL2CPP's `NullChecks` option switched off, see `Il2CppSetOption`) kills the process with `SIGSEGV`, and without `Segv`/`Bus` in the set that crash is not reported at all (observed: the app died with signal 11, the next launch saw no crash). The same IL2CPP behaviour was observed on an HONOR WOD-LX1 (Android 14, Unity 2022.3 IL2CPP, Release): no crash for managed null references, a reported crash (`RelaunchedAfterCrash`) for the unchecked access. The Android SDK has the same selector (`capture.crash-signals`, module `bugsee-android-ndk`, default `Default`, which it resolves to every signal); the wrapper sends `CrashSignals` to both platforms, and the same advice applies. The checks above ran with the default. The sample scenarios `nullref` and `nullrefnochk` reproduce both cases. **Null references on Android with the Mono backend.** Mono on Android is ARMv7 only (Unity ships no ARM64 Mono runtime) and can implement null checks with a SIGSEGV handler, and the Android NDK crash handler is installed ahead of it, which suggested that a managed null reference there might be reported as a native crash ([#233](https://github.com/bugsee/bugsee-unity/issues/233)). On the configurations checked it was not reported as a crash. Checked on one device, an HONOR WOD-LX1 (Android 14, Android SDK 7.4.2, `DetectAndReportCrashNdk` at its default of on, the NDK handler armed with `Crashpad re-armed with linker handler`), with two Mono builds of the sample's `nullref` scenario. (1) Unity 2022.3, Development build: the caught, coroutine and thread-pool `NullReferenceException`s were managed exceptions, the process kept running and the next launch saw no `RelaunchedAfterCrash`. (2) Unity 6000.0.84f1, Release build (no Script Debugging): the same, and on the staging dashboard the uncaught coroutine exception arrived as a managed `Handled` error (`Handled System.NullReferenceException at Bugsee.Sample.NullRefE2E+d__8.MoveNext () (NullRefE2E.cs:95)`, type error, `scripting_backend: mono`, symbolicated with file and line), not as a crash: the run produced no crash issue, no `Fatal signal`/`SIGSEGV` in the log and no `RelaunchedAfterCrash`. The same scenario on a 6000.0.84f1 IL2CPP Release build also reported managed errors only, while `nullrefnochk` there still produced a native `SIGSEGV` crash, as intended. Not established: whether Mono raised these exceptions through its SIGSEGV handler or through explicit checks (the result is that no phantom report appeared, not that the signal path ran), other Unity versions and devices, and whether the SDK wrote a dump. The NDK default is unchanged; if you see a phantom crash on a Mono build, set `DetectAndReportCrashNdk` to false there (this also turns off reporting of real native crashes). `CrashSignals` without `Segv` and `Bus` (see above) is the narrower switch, but it was not tried on a Mono build and it also stops real faults from being reported. Three keys have no property: `capture.logs.oslog` (the iOS SDK accepts and ignores it, permanently disabled), `capture.status-bar-info` (only a DEBUG build of the SDK reads it; the published SDK never does) and `capture.mach-exceptions` (removed from the SDK, which ignores it with a warning; use `CrashHandlerType`). ### Data limits, pending reports, sampling and NDK launch options These Android options (#96, and `CrashSignals`) have typed properties and `Options` constants. `MaxDataSize`, `MaxPendingReports` and `MaxPendingReportAge` (iOS from SDK 7.0.0), `NotifyFlushDelay` and `CrashSignals` are on every launch options type and reach both SDKs; the rest are on `AndroidLaunchOptions` and are Android only (the wrapper drops them before an iOS launch, `OptionPlatformGate`). | Property | Key suffix | Type, default | |---|---|---| | `MaxDataSize` (both) | `config.max-data-size` | int MB, 150 on both platforms (iOS before 7.0.0 defaulted to 50 and did not enforce it). A value below 10 is raised to 10 (on iOS per the 7.0.0 header, not measured); over the limit whole pending reports are deleted (errors first, then bug reports, then crashes, oldest first, never the newest crash; Android also keeps a report being sent), so a low value loses reports sooner. The iOS enforcement is from the 7.0.0 header, not measured on a device | | `NotifyFlushDelay` (both) | `config.notify-flush-delay` | int ms, 0. Coalescing window before the queue of `Bugsee.Notify` calls drains; 0 posts as soon as the item is on disk | | `MaxPendingReports` (both, iOS from 7.0.0) | `config.max-pending-reports` | int, 30; below 1 is raised to 1. Evicts in the same order as `MaxDataSize` | | `MaxPendingReportAge` (both, iOS from 7.0.0) | `config.max-pending-report-age` | int days, 30. Older pending reports are deleted whatever their type; 0 or negative disables aging | | `DetectAndReportExitLowMemoryBackgroundAsError` | `detect.exit.bg_low_memory_as_error` | bool, false. Reports a low-memory kill of a background process as a non-fatal error, not a crash (needs `DetectAndReportExitLowMemory` and a device that reports such kills) | | `DetectAndReportHangSampling` | `detect.hang.sampling` | bool, true. Needs `DetectAndReportHang` | | `DetectAndReportAnrSampling` | `detect.anr.sampling` | bool, true. Needs `DetectAndReportExitNotResponding` | | `DetectAndReportCrashNdk` | `detect.crash-ndk` | bool, true; also off when `DetectAndReportCrash` is false | | `CrashNdkIncludeTombstoneLogs` | `crash-ndk.tombstone-logs` | bool, false. Privacy: the OS tombstone's raw log buffers bypass Bugsee's log filters and are uploaded unredacted | | `CrashSignals` (both; Android needs the NDK extension) | `capture.crash-signals` | `[Flags] CrashSignals` bit set, `Default` (every signal on both SDKs; iOS drops `Segv`/`Bus` only for its Xamarin/.NET wrappers, not for Unity) is right for Unity: leave it alone, see the note above. The bit values are the same on iOS and Android. Differences: leaving out `Abrt` stops uncaught Objective-C exceptions from being reported (iOS); on Android a value that selects none of the six signals other than `None` (for example `64`) is taken as every signal, and `Default` is only honoured on its own on both | The NDK keys (`detect.crash-ndk`, `crash-ndk.tombstone-logs`, `capture.crash-signals`) belong to the `bugsee-android-ndk` extension. The Android SDK knows them only once that extension has registered, and drops them otherwise (they are then missing from `GetLaunchOptions`). The Bugsee Gradle plugin (applied on AGP 8.6+, Unity 6) removes the NDK, Feedback, Leak and Remoting AARs' own registration providers from the manifest and is meant to register them from `BugseeInitProvider.initializeExtensions()`; on Unity 6000.0.84f1 with AGP 9.0.0 and plugin 4.0.8 that method was empty, so nothing registered the extension (observed; AGP 8.6 to 8.10 unverified, [#226](https://github.com/bugsee/bugsee-unity/issues/226)). That is a plugin problem; the wrapper works around it: its `UnityWrapperProvider` registers each of those extensions that the app carries before `Application.onCreate` and `Bugsee.Launch`, so the keys work there too. An app that adds `bugsee-android-leak` itself can set the leak keys on Android with `SetCustomOption`; the wrapper registers that extension too. The memory-leak and thread-leak options (`detect.memory_leaks*`, `detect.thread_leaks`) belong to the `bugsee-android-leak` module, which the wrapper does not ship; they have no property and the wrapper drops them from an iOS launch. ## Lifecycle: Launch, Relaunch, Stop, Delete `Launch`, `Relaunch`, `Stop` and `DeleteCollectedDataOnDevice` do not wait for the native SDK to finish. They are handed to the Unity main thread. Called from another thread, on Android the call is queued there and never refused (it waits for the main thread). On iOS the caller waits up to 5 s for the main thread to take it; if it does not, the request does not run (an error is logged, `LaunchAsync`/`RelaunchAsync` complete `false`, `StopAsync` faults with `TimeoutException`). Ordering differs per platform, and holds for the wrapper's scheduling before the hard deadline below: - **Android**: `Launch`, `Relaunch` and `DeleteCollectedDataOnDevice` run one at a time, in request order. A queued `Launch` replaces earlier queued `Launch`/`Relaunch` requests after the last queued Delete, and a `Relaunch` that is still queued folds its options into the queued request before it (they then run as one request, which replaces the option set as described under Launch / Relaunch). On Android (SDK 7.4.2) a `Relaunch` requested while a `Relaunch` is in flight, with nothing queued and no `Stop` since, joins it: it gets that relaunch's outcome and its own options are IGNORED (a warning says so), so they do not replace the option set. `Stop` is not queued behind them: it starts (or joins) a native stop at once and drops every queued `Launch`/`Relaunch`. A queued Delete is never dropped, and a Delete does not cancel `Launch`/`Relaunch` requests queued before it: they run first. - **iOS**: only stops and the delete's wipe are serialized, one native operation at a time. A `Launch`/`Relaunch` requested while a stop or a wipe is in flight is deferred until the SDK reports it finished. A later `Launch`/`Relaunch` replaces a deferred one, and a later `Stop` or `DeleteCollectedDataOnDevice` cancels it (it completes `false`). A Delete is never skipped because a `Launch` follows it: that `Launch` waits and runs after the wipe. What each call guarantees: - **Stop**: its completion runs when the SDK has reported the stop finished, or at the soft deadline. A `Launch`/`Relaunch` requested during the stop waits for it, and the completion runs before that `Launch` does. If the completion itself calls `Launch`, that later request replaces the waiting one (it completes `false`) and is the one that starts. On iOS the completion is dropped only if the call never ran (the 5 s hand-off) or an earlier completion of the same stop already launched; `StopAsync` completes either way. To change the token or options of a running SDK, call `Stop` and launch from its completion. - **Relaunch on Android** (SDK 7.4.2): the callback always runs, exactly once. A `Relaunch` the SDK refuses (not launched, still launching, stopping) completes `false` at once, with no deadline involved. A second `Relaunch` while one is in flight joins it: it completes with that relaunch's outcome (`true` once it launched) and the options it passed are IGNORED, the options of the call that started it apply. A `Stop` that arrives while the relaunch is stopping, or before its launch has begun, CANCELS it: the SDK stays stopped and the relaunch completes `false`, before the `Stop` completion runs (`StopAsync` is answered as soon as the SDK reports the stop). The same cancel happens when the wrapper only wants to wait for a stop it did not start (a relaunch made from Java, or one abandoned at the 60 s reset with a request queued behind it): the wrapper's stop call cancels it. A `Stop` while the relaunch is already launching is a plain stop: the launch completes `false`. A `Launch` requested during a relaunch's stop waits for the relaunch and then finds its session running, so its token and options are ignored. - **Launch / Relaunch**: starts a session when the SDK accepts it. A Launch while the SDK is already running ignores the new token and native options. On Android it also leaves the managed capture hooks unchanged; on iOS the managed capture options are applied again, so a repeated `Launch` with different capture options can change (or switch off) managed capture of a running session. Android ignores a `Relaunch` unless the SDK is `Launched`. - **Relaunch replaces the option set, it does not merge**: on both platforms the options passed to `Relaunch`/`RelaunchAsync` become the whole option set. The one exception is an Android `Relaunch` that joins a relaunch already in flight: its options are ignored, the options of the call that started it become the option set. Every native option you leave out, `Endpoint`, `CaptureManagedExceptions` and `CaptureUnobservedTaskExceptions` go back to their defaults, and a `Relaunch()` without options resets every option to its default (handlers, filters and the lifecycle listener are kept). `TreatUnityLogExceptionsAsFatal` is the exception: it is read when the managed exception hooks are installed, so a `Relaunch` that keeps them installed does not change it; a `Stop`, or a `Launch`/`Relaunch` the SDK accepts with `CaptureManagedExceptions` off, removes the hooks and the next launch reads it again. To change one option, pass the full option set again with that option changed. - **DeleteCollectedDataOnDevice**: stops the SDK if needed (joining a stop in flight), then deletes the data collected on the device, including finished report bundles, and leaves the SDK stopped: call `Launch` again to resume. It has no result. A failure is only logged: on iOS a warning when the SDK reports the wipe failed or had not finished stopping, on Android a warning when the native delete fails or does not answer in time. To be told the result, or to delete less, use `DeleteCollectedDataOnDeviceAsync(DeleteScope scope = DeleteScope.Everything)` (a `Task`) or the synchronous `DeleteCollectedDataOnDevice(DeleteScope scope)`. `DeleteScope.CaptureOnly` deletes the recorded capture and keeps the report snapshots and the report bundles waiting for upload (Android `includingIntermediate=false, includingBundles=false`, iOS `includingIntermediate:NO`); `CaptureAndIntermediate` also deletes the report snapshots (Android `true, false`, iOS `includingIntermediate:YES`); `Everything` is the default and what the plain call does. The task completes true when the SDK reported the data deleted and false when it refused, gave no answer in time or, on iOS, the call did not reach the Unity main thread within 5 s (nothing was started). A timeout is a false, not a `TimeoutException` as with `StopAsync`. On Android the time is counted from when this delete starts (after the operations requested before it) and includes its stop: 10 s. On iOS the stop and the wipe each give up after 60 s, so up to about 120 s, more behind another wipe. The wipe can still finish after a false. The SDK is left stopped either way. A value that is not a `DeleteScope` throws `ArgumentOutOfRangeException`. Requests run in request order. On iOS, when no launch is deferred behind the wipe, a delete of the same scope as the wipe in flight shares that wipe and its result (a launch requested before it is cancelled by it, and it then gets its own wipe), and one of another scope waits for it and then starts its own (never two native wipes at once while the first is within its 60 s hard deadline: after that give-up a queued wipe of another scope may begin while the abandoned native wipe is still running), so a narrow request is never widened. "Kept" means the native SDK's data on disk only: as with `Stop`, an unfinished managed `IReport` and an in-flight managed upload are dropped by every scope. On Android a delete queued behind one that has not started shares its wipe when it has the same scope; one that arrives while another is already running is a wipe of its own. On the other players, the Editor included, nothing is collected and the task completes true. Async variants: - `LaunchAsync` / `RelaunchAsync` return `Task`: `true` when the SDK accepted the launch, `false` when it refused it or a later request cancelled it (which requests cancel a waiting launch is the per-platform ordering above). If the SDK gives no answer within 10 s, they complete `true` when its status is `Launching`/`Launched` and `false` otherwise. - `StopAsync` returns `Task` and completes when the SDK has reported the stop, even if a Launch follows. It faults with `TimeoutException` when the SDK has not reported the stop within 10 s of that call (a call that joins a stop in flight has its own 10 s), and on iOS also when the main thread did not take the call within 5 s. On Android the Task stays pending if the Unity main thread is stalled, because the 10 s deadline is driven from the main thread. Deadlines, for an SDK that does not report back (the Android SDK 7.4.2 always does, so there they only guard a stalled native call such as a slow stop or capture start; a refused relaunch no longer needs one): - **10 s (soft)**, from when the call started: the caller is answered with a warning, and nothing else is released. A `Stop` completion runs, `StopAsync` faults, and on Android an in-flight `Launch`/`Relaunch`/`Delete` answers its internal completion. The native operation stays in flight: a `Launch`/`Relaunch` requested meanwhile still waits for it, and the SDK may still finish it. On Android that includes a delete already handed to native, which can complete after the 10 s warning. - **60 s (hard)**: the wrapper stops waiting for a stop and moves on, with a warning. On iOS this also covers a wipe; on Android also an in-flight launch, relaunch or delete. A late report from the SDK is ignored by token. An iOS `Launch`/`Relaunch` already handed to the SDK has no hard deadline, only the 10 s status answer. Residual races after the hard deadline (the native SDKs cannot cancel an operation, so these are accepted): - **iOS**: a deferred `Launch` is released at the give-up, so if the native stop is in fact still running it can stop a `Launch` made after the hard deadline. A wipe still running when its deferred `Launch` is released overlaps that launch in the same way. - **Android**: a late `Launch`/`Relaunch` result arriving after the reset is ignored, so the managed capture hooks can be out of step with that session until the next lifecycle call. (The SDK itself stays stopped when a `Stop` was requested: it cancels a launch or relaunch in flight, so a late result never restarts a stopped SDK.) - **Android**: after the reset of a delete, a queued `Launch` can run while the native delete is still wiping. A `Delete` started after the reset of a relaunch stops the SDK first, and in SDK 7.4.2 that `stop()` cancels the abandoned relaunch, so the two overlap only when the SDK is already `Stopped` while the relaunch has not launched yet. ### Lifecycle events `Bugsee.LifecycleEvent` and `ILifecycleEventListener.OnEvent(eventType, data)` behave alike on both platforms. `data` is `null` or a `string` (the snapshot or request id of the report events); the native SDKs send nothing else today. If an SDK ever sends a map it arrives as a `Dictionary` on both, with numbers inside it as `long`/`double` on iOS and `int`/`float` on Android; on iOS any other payload type arrives as its description text, and a map nested deeper than the JSON reader allows as raw JSON text. Events the SDK announces before the managed side is listening (for example from a launch the host made natively before any C# call) are held, up to 128, and delivered in order shortly after the wrapper starts listening (on iOS on the main queue after the `Launch` or `Relaunch` call that registered it, on Android on the next main-looper pass), on both iOS and Android. `Relaunch` registers the wrapper the same way `Launch` does. Handlers run on the Unity main thread on iOS and Android alike. Other platform differences, not aligned: - Before `Launched`, iOS holds network and breadcrumb events in the wrapper and submits them at launch, while Android hands them straight to the SDK. - `IReport.Email` set on a report from `CreateReport` is used on Android; on iOS it is dropped with a warning (the managed upload cannot carry it): use `SetUserIdentifier` there. - `IAppearance.ToMap()` returns what the SDK reports on Android; on iOS it lists only the properties set through the wrapper that the native theme applied. - `ResetVideoCapturePermission()` forgets the stored screen-capture decision on Android; it matters only with `VideoMode.Fullscreen` and `CaptureVideoFullscreenRememberUserDecision`, has no effect before launch (the SDK only warns in logcat), does not change a session that is already capturing, and applies to the next capture start. iOS has no such permission, so the call does nothing there and logs a warning once per process; in the Editor it does nothing. - Per-report screenshots (`IReport.ScreenshotDisplayIds`, `GetScreenshotPng`, `SetScreenshotPng`, `IsScreenshotChanged`, #224) work on the report a report handler receives (`SetReportHandler`, before and after phase), on Android and iOS, and are not available on a report from `CreateReport` (a managed snapshot with no captured screenshot: the getters return nothing, a set returns false and warns once). `exportVideo` is not exposed. See "Report screenshots" below. To omit the SDK's screenshot from reports use `CaptureScreenshot = false`; secure rectangles and blackout only redact what is captured. `AddAttachmentFile` / `AddAttachmentBytes` add files; they cannot remove, replace or redact the SDK's screenshot. - `Trace(name, value)`: both platforms send a map, list or array as the same JSON (see "Trace values"); the iOS SDK receives it as a structure (a dictionary or array), the Android SDK as a string. ## Report screenshots In a report handler (`Bugsee.SetReportHandler`), the report's per-display screenshots can be listed, read, replaced and removed as PNG bytes: ```csharp public override void OnBeforeReportCreated(IReport report, bool isTerminating, Action done) { foreach (var display in report.ScreenshotDisplayIds) // usually just 0 { byte[] png = report.GetScreenshotPng(display); // null: not listed, or listed but unreadable (see below) // report.SetScreenshotPng(display, redactedPng); // replace // report.SetScreenshotPng(display, null); // remove } done(); } ``` - Works in both phases on Android (the live Java report) and iOS (the live native report, addressed by the handler's request); after the handler has answered, was skipped or abandoned, the getters return nothing and a set returns false with a warning once. A report from `Bugsee.CreateReport` never holds screenshots (see above). The Editor has no report handler, so there is nothing to call there. - Call from the handler on Unity's main thread, inside its turn. `GetScreenshotPng` blocks that thread while the SDK produces the PNG (it waits for the SDK's answer with no timeout of its own). - `SetScreenshotPng` returns true when the report took the change. It returns false, with a warning, for data that is not a PNG (no signature), over 32 MiB (`ReportScreenshotPolicy.MaxPngBytes`; also the limit for what a read returns), a PNG with a zero or unreadable size, a side over 8192 pixels or more than 33554432 pixels in total (`ReportScreenshotPolicy`; a small file can declare a huge canvas), or a PNG the platform cannot decode. `null` removes the display's screenshot. Android decodes the bytes with `BitmapFactory`, iOS with `UIImage`, so the stored pixels are what the platform makes of the PNG. - On iOS a screenshot edit reaches the native report immediately, so it stays even if the handler later throws or answers after the SDK's deadline; the other report edits travel in the handler's result and are dropped then. Android edits are live too, but stop at the end of the handler's turn. - `GetScreenshotPng` returns null both for a display with no screenshot and for a listed display whose screenshot cannot be read (too large, over 32 MiB as PNG, or not encodable by the platform; a warning says so). Test `ScreenshotDisplayIds`: a null for a listed display is not "nothing to redact", replace or remove it. - `IsScreenshotChanged` becomes true when a screenshot the report holds is replaced or removed, on both platforms. Adding a screenshot to a display that held none does not set it (both SDKs count changes to an existing entry), so do not use it to detect your own first set. - **Privacy.** A screenshot is the screen as captured and can show personal data and content you marked secure; secure rectangles and blackout redact the capture, and nothing here re-checks a bitmap you read or replace. Do not log the bytes or send them anywhere the report does not go. A screenshot you set replaces the captured one in the report and its upload, with no redaction added for you. To send none at all use `CaptureScreenshot = false`. - The gate that ends the handler's turn is checked before each call, not locked across it: a call that races the end of the turn on another thread can still land (the attribute setters have the same window), which is why the calls belong on Unity's main thread inside the turn. - Sample scenario `screenshots` checks all of this on a device. ## Crash & exception capture | Source | API / option | Severity default | |---|---|---| | Manual | `Bugsee.LogException` | non-fatal | | Manual unhandled | `Bugsee.LogUnhandledException` | fatal | | Unity `Debug.LogException` / routed exceptions | ExceptionPipeline | non-fatal (set `TreatUnityLogExceptionsAsFatal`) | | `AppDomain.UnhandledException` | ExceptionPipeline | fatal | | `UnobservedTaskException` | ExceptionPipeline (`CaptureUnobservedTaskExceptions`, default on) | non-fatal | | Native abort / signal | `DetectAndReportCrash` + native SDK | fatal (next launch) | | Android hang | `DetectAndReportHang` | hang report | | Android ANR / OOM | `DetectAndReportExitNotResponding` / `DetectAndReportExitLowMemory` | exit reports | **iOS and tvOS simulator:** the SDK's simulator build has no crash reporter (bugsee-cocoa#241), so native crashes (`DetectAndReportCrash`, `Bugsee.TestCrash`), hang detection, `LogError` and managed exceptions, handled (`LogException`, `Debug.LogException`) and unhandled (`LogUnhandledException`, `AppDomain.UnhandledException`), are **not reported** there; they are reported only from a device. Manual bug reports and uploads, logs, events and video still work. The package warns once at the first launch (`[Bugsee] Running on the simulator` in the Unity log, and in the native log). Validate crash and exception reporting on a physical device. Managed exceptions use the **UnityManagedException** JSON-in-reason contract (`name`, `reason`, `frames[{trace,address?}]`, `signature`, `buildID`, `moduleUUID`, optional nested `cause`). The nested `cause` reaches the SDK and the server inside the reason text, but the worker does not read it yet (see the managed-stack notes below): until it does, only the outermost exception is shown, symbolicated and grouped; the inner exceptions are not displayed. ### Managed exceptions the SDK cannot see (ThreadPool on Mono, tasks) Managed capture (`CaptureManagedExceptions`) registers these hooks, during launch (`Runtime/Internal/ExceptionPipeline.cs`): - a wrapper around `Debug.unityLogger.logHandler` (its `LogException`); - `Application.logMessageReceivedThreaded`, as a fallback for exceptions Unity logs without going through the handler (an echo of an exception already reported is dropped); - `AppDomain.CurrentDomain.UnhandledException`; - `TaskScheduler.UnobservedTaskException` (not on `NET_LEGACY` profiles; `CaptureUnobservedTaskExceptions`). There is nothing else (no `FirstChanceException`). An exception that reaches none of these is not reported. **An exception thrown in a `ThreadPool` work item on the Mono backend is lost** (measured on Unity 2021.3.45f1, Android ARMv7; other Unity versions not measured). With `ThreadPool.QueueUserWorkItem(_ => throw ...)` on Android Mono (ARMv7), Unity logs nothing, `AppDomain.UnhandledException` is not raised and the process keeps running, so no managed hook can see it and the SDK reports nothing. This does not involve the SDK: it was reproduced in a player built without the Bugsee package. On IL2CPP the same code raises `AppDomain.UnhandledException` and the SDK reports it (twice, as a handled and a crash-type event, because Unity also logs it). A `new Thread` that throws is logged by Unity and reported on both backends. Workaround: catch inside the work item and report it with `Debug.LogException(e)`, not `Bugsee.LogException(e)`: ```csharp ThreadPool.QueueUserWorkItem(_ => { try { DoWork(); } catch (Exception e) { Debug.LogException(e); } // the SDK's log-handler wrapper reports it (CaptureManagedExceptions, on by default) }); ``` Why `Debug.LogException` and not `Bugsee.LogException` from a pool thread (from reading the code; not run on a device): the log-handler wrapper builds the payload on the calling thread but queues the send to Unity's main thread (`ExceptionPipeline.DispatchPayload`, `MainThreadDispatcher.Run`), so the report is filed on the next main-thread frame. On Android `Bugsee.LogException` builds the Java objects (`AndroidBridge.SendManagedPayload`) and calls the SDK on the calling thread, and that call, unlike the span calls, is not wrapped in an attach (`AndroidJniScope`). The JVM aborts the process on a JNI call from an unattached thread (see the spans note below), so do not call `Bugsee.LogException` from a thread-pool or other background thread on Android unless you attach it first (`AndroidJNI.AttachCurrentThread()` before; call `AndroidJNI.DetachCurrentThread()` after only if your own attach created the attachment, because attaching an already attached thread succeeds without telling you and a detach would then remove someone else's attachment, so when unsure leave the thread attached, or run the call on the main thread instead; the sample scenario `sigthreads` does this on a dedicated `new Thread`, not a pool thread). Whether that unattached call really aborts was not run for `Bugsee.LogException`. `Debug.LogException` also prints the exception to the Unity log, and it needs the managed capture on: with `CaptureManagedExceptions` off nothing is reported, and with `TreatUnityLogExceptionsAsFatal` the report is fatal and the calling thread waits up to 4 s for the main thread. **`Task.Run` and an `async Task` whose result is dropped** store the exception in the `Task`; nothing is logged. The SDK reports it only when the runtime finalizes the faulted task and raises `TaskScheduler.UnobservedTaskException` (as a handled error with the stack of the throw). That depends on garbage collection, so the report can arrive late, or not at all if the app exits first or no collection finalizes the task. Await your tasks, or handle faults (`ContinueWith(..., TaskContinuationOptions.OnlyOnFaulted)`), and report them with `Debug.LogException` (a continuation usually runs on a pool thread, see above; on Android `Bugsee.LogException` is safe there only on the main thread or a thread you attached). `async void` methods that run on the Unity main thread and coroutines are logged by Unity and reported normally (measured). An `async void` method started from a `ThreadPool` work item on Mono was not measured; expect it to be lost like a synchronous throw there, so catch and report inside it. What was measured: Unity 2021.3.45f1, a physical Honor WOD-LX1 (Android 15; Mono ARMv7 and IL2CPP ARM64, Release builds, and Development for Mono) and an iPhone XS (iOS 18.7.9, IL2CPP Release), each with and without the SDK where noted above. The same probe also threw from a bare `new Thread`, an `async void` method that awaits a faulting task and a coroutine: Unity logged each on every backend tested, and with the SDK each was reported (on the iPhone and the Honor Mono Release build). The pool loss was seen on both Mono Release and Development without the SDK, and in a Release build with it. With a forced `GC.Collect()` plus `GC.WaitForPendingFinalizers()` (at 8 s and again at 11 s after the throw, observed until 16 s; no longer wait, and the event is known to be able to arrive tens of seconds after a collection), 4 of 18 task cases did not raise `UnobservedTaskException` in that window (Mono Release `Task.Run`; IL2CPP Android `Task.Run` and an awaited-then-dropped `async Task`; iOS an awaited-then-dropped `async Task`, without the SDK). Not measured: Windows or desktop players, other Unity versions, other devices. Why the pool case is silent on Mono is taken from knowledge of the Mono runtime source, not verified on symbols of this build: the managed pool dispatch loop has no catch-all, the native pool worker invokes the work item with a call that catches the exception, and Unity sets Mono's legacy unhandled-exception policy, under which that path does not raise `AppDomain.UnhandledException`. A `new Thread` has no catching frame, so the event is raised before the policy is consulted. ### How to get C# class + file:line on `LogException` | Mode | Build / capture | Backend | File:line? | |---|---|---|---| | **A. Rich managed stacks** | Mono **Development Build** (a portable `.pdb` ships next to each assembly), or IL2CPP **Method Name, File Name, and Line Number** (or Script Debugging) | Parse `frames[].trace` | **Yes** (from string) | | **A0. Mono Release** | Mono without Development Build: no `.pdb` in the player, the text is `at Ns.C.M (System.String a) [0x0000b] in :0` | Parse `frames[].trace` | **Method names only in the app; file:line from the BMF mapping that `bugsee-cli` builds from the portable `.pdb` files and the Editor uploads** (Android, `BUGSEE_APP_TOKEN` set, `bugsee-cli` 0.9.0+; see "Mono Release: BMF mapping from portable PDBs"). Without that upload the IL offset stays unresolved. A Development Build has file:line for assemblies Unity compiles (not for store builds; a managed plug-in without a `.pdb` stays IL-offset only); IL2CPP has it only where Unity offers IL2CPP line information. | | **B. Release Method-only + LNM** | IL2CPP **Release** (not Development); thrown exception; SDK emits native IPs via `il2cpp_native_stack_trace` | PC → dSYM/ELF **with DWARF line info** → LineNumberMappings | **Android, Unity 6000.0.84f1: yes with full symbols** (needs `il2cpp-linemap` and symbols with line info: Create symbols.zip = Debugging, not Public; addresses are module-relative). iOS and Unity 2022.3 are not verified for this. Not for Development builds (see below) | | **C. MethodMap only** | IL2CPP mangled names; map uploaded | MethodMap.tsv demangle | **Names only** (no invented `.cs:line`) | Mode **B** follows the same capture idea as Sentry (`il2cpp_native_stack_trace` on a thrown exception). Prefer: ```csharp try { DoThing(); } catch (Exception ex) { Bugsee.LogException(ex); } // real thrown exception ``` `new Exception("…")` never thrown cannot get Mode B lines. Unity **Stack Trace Log Type** does not rewrite `Exception.StackTrace`. ### Competitors (summary) | | Managed `Notify`/`CaptureException` file:line on Release IL2CPP | Upload LNM | Native fatal → C# line | |---|---|---|---| | **Sentry** | Yes — IL2CPP backend IPs + server LNM | Yes | Yes | | **Bugsnag** | Yes when maps+symbols uploaded (mobile) | Yes (CLI fail-closed unless opt-out) | Yes | | **Firebase** | Relies on Unity managed stack settings; strong native symbols.zip | Not emphasized | Yes (NDK/dSYM) | | **Backtrace** | Prefer real `Exception` object; WebGL no C# lines | symbols.zip focus | Yes | | **Bugsee** | Mode A; Mode B path shipping (IPs + LNM; prove end-to-end); Mode C names via MethodMap | Yes | Yes (S1/S2) | IL2CPP **C# file/line** via LNM always needs uploaded `il2cpp-linemap` + matching dSYM/ELF with **line** info (and for Mode B, instruction addresses on the event). ### Mono Release: BMF mapping from portable PDBs An Android build on the Mono scripting backend that is not a Development Build ships no `.pdb`, so the runtime prints a managed frame as `at Ns.C.M (System.String a) [0x0000b] in :0`: a method, an IL offset and the id (MVID) of the assembly, no file or line. After such a build the Editor runs `bugsee-cli debug-files upload P.dag> --type portable-pdb --shipped-dir --version --build `. The CLI does **not** upload the `.pdb` files: it converts each assembly Unity compiled, with the portable `.pdb` beside it, into Bugsee's BMF mapping format (one `.bmf` per assembly, the same output as `bugsee-cli debug-files convert --to bmf --shipped-dir --output `, which you can run locally to inspect it) and uploads those BMFs. The BMF is keyed by method signature and IL offset and registered under the module id of the *shipped* assembly (managed stripping Low or higher gives the assembly a new id), and methods the linker removed or rewrote are left out. The backend resolves the frame to `File.cs:42` from the BMF. - Needs `bugsee-cli` 0.9.0 or newer (the pinned release is). An older CLI found on the search path, in an install directory or in the package cache (for example a 0.8.1 that the other uploads accept) is passed over for this step: the Editor takes the first CLI of 0.9.0 or newer in the lookup order below (search path, install directories, the package's cache of the step's release: 0.9.0, or `BUGSEE_CLI_VERSION` when that is 0.9.0 or newer), else downloads that release into the cache (a token is set, as this step needs), and logs which CLI it took. The release is 0.9.0, or the `BUGSEE_CLI_VERSION` you set when that is 0.9.0 or newer (a lower value is ignored for this step). A `BUGSEE_CLI_PATH` that names an older CLI, as a path or as a bare command name, is not replaced: the Editor logs a warning naming it and skips the step. When no CLI of 0.9.0 or newer is found, the same warning appears if the download is not possible (`BUGSEE_NO_CLI_DOWNLOAD` is set, a download failed in this build or earlier in this Editor session, or no release is published for the host). The build continues in every case; the other uploads of the build keep using the CLI of the shared lookup below. - Runs when `BUGSEE_APP_TOKEN` is set in the Editor's environment and `BUGSEE_NO_SYMBOL_UPLOAD` is not. Otherwise a one-time warning gives the manual command. It is not run for a Development Build (it ships its `.pdb` files), for IL2CPP (line map) or on iOS (no Mono backend). - The compiler folder is the newest `Library/Bee/artifacts/P.dag` that was compiled for Android (its `*.rsp` defines `UNITY_ANDROID`; the prefix differs by build target, so an iOS folder in the same project is never taken; `...PDevDbg.dag` is the Development player and `...E.dag` the Editor, whose module ids the app never has). A failure, a missing folder or a non-zero exit is a warning; the build is never failed. - `ManagedStripped` must be at least as new as the compiler folder (the linker runs after the compile) and, among several Android release folders, the one used is not newer than it. When more than one Android release folder exists the Editor warns and names them, since the file times cannot say which one Unity reused (delete the ones you no longer build with). If the folder is missing or older than the compiler folder the upload still runs, under the compiler's module ids, and the Editor warns: that matches the app only with managed stripping Disabled. Managed stripping Disabled and Export Project builds were not run, so whether Unity refreshes `ManagedStripped` then is not established. - A managed plug-in dll with no `.pdb` beside it is not uploaded and stays IL-offset only. - Verified on a Samsung SM-T725 (Android 11, Unity 2021.3.45f1, Mono, Release, `pipeline` scenario, staging): the player printed `E2EThrowStableA (System.String marker) [0x0000b] in <2d446532fd384305b361aaee300be307>:0`, the build log showed the CLI uploading the BMF of `Assembly-CSharp` under that module id, and the staging issue showed `E2EThrowStableA (System.String marker) (BugseeSampleBootstrap.cs:1243)`. Managed stripping Low (the sample's setting) was the only one checked, and only on 2021.3. ## Symbol upload (Editor / CI) Set `BUGSEE_APP_TOKEN` in the environment (opt-in). Optionally `BUGSEE_CLI_PATH`, `BUGSEE_VERSION`, `BUGSEE_BUILD`, `BUGSEE_IL2CPP_MAPPING`, `BUGSEE_IL2CPP_UUIDS`, `BUGSEE_BUILD_UUID`. The iOS Run Script passes `--version` / `--build` from `BUGSEE_VERSION` / `BUGSEE_BUILD`, else from the built app's Info.plist (what the SDK reports; a Unity export sets no `MARKETING_VERSION` / `CURRENT_PROJECT_VERSION`), else from those two build settings; a flag with no value is omitted. **Build token vs `Launch` token.** Symbols, mappings and the Android synthesized build id follow `BUGSEE_APP_TOKEN` at build time, crashes follow the token given to `Bugsee.Launch`. When they name different apps, symbols sit in another app than the crashes and nothing says so. When an Android symbol upload is on (a token set, `BUGSEE_NO_SYMBOL_UPLOAD` unset), the build records a fingerprint of its token (the first 8 bytes of SHA-256 of the trimmed token, as 16 hex characters; never the token) as the Resources asset `BugseeBuildTokenFingerprint`, present only while the build runs (removed afterwards; nothing stays in `Assets`, an empty `Assets/Resources` the build created is removed too). `Bugsee.Launch` in a player logs one warning, naming both fingerprints, when its token has another fingerprint (once per process: a Stop then Launch with another token does not warn again). It is silent when they match, in the Editor, and for a build that recorded none. Set `BUGSEE_NO_TOKEN_CHECK` for the build to record nothing, e.g. when the token is chosen at runtime (staging vs production app). The fingerprint asset is a file in `Assets/Resources` while the build runs: a version-control plugin that locks or tracks files (Perforce, Plastic) may notice it. **iOS.** The symbols are uploaded by the Xcode Run Script with the token of the Xcode environment, which the Unity build cannot see, so the Run Script itself records the fingerprint (same recipe) as the key `BugseeBuildTokenFingerprint` of the built app's Info.plist. The phase runs before Xcode signs the product, so the edit is covered by the signature, and it is rewritten (or the key removed: no token, `BUGSEE_NO_TOKEN_CHECK`, `BUGSEE_NO_SYMBOL_UPLOAD` set, or a Debug upload skipped by `BUGSEE_SKIP_UPLOAD_ON_DEBUG`) on every build, so an incremental build never keeps an earlier token's fingerprint. `Bugsee.Launch` reads it and logs the same one warning on a mismatch. Set `BUGSEE_NO_TOKEN_CHECK` in the Xcode environment (or as a user-defined build setting; setting it in the Unity Editor at export does nothing) when the token is chosen at runtime. It is recorded whether or not bugsee-cli is found and the upload succeeds, and the plist keeps its format (a binary one stays binary). A token with a line break inside it records nothing. Not done on tvOS (the key is not written there). ### Where `bugsee-cli` comes from (Editor uploads) This lookup serves every Editor upload on any platform that uses the CLI from the Editor (the Android mapping and symbols, and the IL2CPP linemap upload of a standalone or Android build). A Unity Editor started from the Hub or the Finder does not inherit your shell's `PATH`, so a CLI installed with Homebrew or `install.sh` is often invisible to it. The Editor uploads therefore look, in order, at: `BUGSEE_CLI_PATH`; the Editor's `PATH`; the places the installers use (`/opt/homebrew/bin`, `/usr/local/bin`, `~/.local/bin`, `~/.cargo/bin`, `~/.bugsee/bin`, `%LOCALAPPDATA%\Bugsee\bin`); the package's cache (`~/Library/Caches/Bugsee/cli` on macOS, `$XDG_CACHE_HOME/bugsee/cli` or `~/.cache/bugsee/cli` on Linux, `%LOCALAPPDATA%\Bugsee\cache\cli` on Windows, else `Library/Bugsee/cli` in the project). An installed CLI older than 0.8.1 is passed over (0.8.1 replaces a stored symbol table with DWARF for the same build id without `--force`, which the uploads never pass; the pinned release is downloaded instead when a token is set; only the Android ELF upload needs 0.8.1, but the IL2CPP linemap upload shares the lookup and so the floor: with `BUGSEE_NO_CLI_DOWNLOAD=1` and only a 0.8.0 installed it finds no CLI). A too-old CLI you name with `BUGSEE_CLI_PATH` is used, with a warning that stored symbol tables are not upgraded. The Android Mono Portable PDB step needs 0.9.0 and applies its own higher floor on top of this lookup (see "Mono Release: BMF mapping from portable PDBs"): when the CLI found here is older it takes the first CLI of 0.9.0 or newer in this order, else the cached or downloaded pinned release. When none is found and a token is set, the pinned release (0.9.0, the Bugsee Gradle plugin's default) is downloaded from `https://download.bugsee.com/cli/v/bugsee-cli-.tar.xz` (`.zip` on Windows, for x64 and ARM64), checked against the SHA-256 pinned in the package for that release (a release you pin with `BUGSEE_CLI_VERSION` is checked against the published `.sha256` only), unpacked into that cache and run once to prove it works. For a release pinned in the package the checksum does not depend on the download host; for any other it comes from the same host as the archive, so it detects corruption, not a compromised host: set `BUGSEE_CLI_PATH` to a binary you vetted if that matters. Credentials in `BUGSEE_CLI_BASE_URL` are not logged. Not verified on a Windows host (the zip and `.exe` paths, the Windows PATH and cache layout and the ARM64 Windows release are covered by unit tests that simulate Windows semantics; see [Windows Editor](#windows-editor) for what a Windows Editor still has to confirm). `BUGSEE_NO_CLI_DOWNLOAD=1` turns the download off, `BUGSEE_CLI_VERSION` pins another release and `BUGSEE_CLI_BASE_URL` points at a mirror (https only), as for `install.sh`. If nothing can be found or downloaded the build warns once, naming what was tried, and continues without uploading. The iOS Run Script has its own lookup, below, and never downloads. `BUGSEE_NO_SYMBOL_UPLOAD` is also read by the Run Script when Xcode runs it (not only by the Unity export): with it set in the environment of the archive, the script prints `Bugsee: skip symbol upload (BUGSEE_NO_SYMBOL_UPLOAD is set).` and uploads nothing (dSYMs and line map), even with `BUGSEE_APP_TOKEN` set. With it set at export, the Editor removes an earlier export's pending-map pointer and writes no new one, and the Append-export sweep deletes nothing (it can still refresh the modification time of files equal to this build's own), so a stale `MethodMap.tsv` or `LineNumberMappings.json` of an earlier export can stay in the export folder: a manual `bugsee-cli debug-files upload` from that folder would pick it up. An Append export made with an older package version is refreshed by a later export with the current package: it rewrites `BugseeScripts/upload-symbols.sh` and updates the `Bugsee Upload Symbols` phase. The refresh happens on every iOS/tvOS export, whether or not the token is set or `BUGSEE_NO_SYMBOL_UPLOAD` is set (those only decide whether the installed CLI's path is baked into the script). Re-export with the current package before relying on `BUGSEE_NO_SYMBOL_UPLOAD` at archive time; setting the variable in Xcode does not change an older script. The iOS Run Script cannot rely on the Editor's lookup: Xcode runs build phases with a minimal `PATH`. `BUGSEE_CLI_PATH` and the CLI the Editor's own lookup finds when it exports the project, without downloading (baked into `BugseeScripts/upload-symbols.sh`; only on a macOS host, with `BUGSEE_APP_TOKEN` set and `BUGSEE_NO_SYMBOL_UPLOAD` unset) are used as given, if the file is executable. Otherwise the first of these that runs, prints a version (`bugsee-cli 0.9.0`) and is at least 0.8.0 (a pre-release such as `0.8.0-beta.1` counts, as in the Editor) wins, in the Editor's order: the build phase's `PATH`; `/opt/homebrew/bin`, `/usr/local/bin`, `~/.local/bin`, `~/.cargo/bin`, `~/.bugsee/bin`; and the package's cache (`~/Library/Caches/Bugsee/cli`, `$XDG_CACHE_HOME/bugsee/cli` or `~/.cache/bugsee/cli`, the pinned or `BUGSEE_CLI_VERSION` release first). Every `PATH` entry is tried, and a `--version` probe is stopped after 15 s (killed 2 s later if it ignores the signal). The script never downloads. The baked path is absolute, so it contains the exporting user's home directory (and username): if you commit the exported Xcode project, set `BUGSEE_NO_SYMBOL_UPLOAD` or unset `BUGSEE_APP_TOKEN` before exporting and nothing is baked. When none qualifies it prints a `warning: Bugsee: bugsee-cli was not found` line naming every path tried and why each was passed over, uploads nothing, and the build continues. The iOS Run Script uploads for **every** Xcode configuration (Debug included, so a crash from a development build is symbolicated) and runs on every build that has the token in its environment, not only archives. Set `BUGSEE_SKIP_UPLOAD_ON_DEBUG=1` to skip the Debug configuration, for example for local Xcode runs. The phase declares the app's and UnityFramework's dSYM files as its inputs (and "Based on dependency analysis" off), so Xcode runs it after the tasks that write them; a configuration without a dSYM leaves those inputs missing, which Xcode accepts. The export also sets `ENABLE_USER_SCRIPT_SANDBOXING = NO` on the Unity-iPhone target: with the sandbox on (the default of new Xcode projects) Xcode refuses to start the phase's script ("Operation not permitted" on `BugseeScripts/upload-symbols.sh`; the build continues and nothing is uploaded), and the script could not read the dSYM folder or reach the network anyway. A project-wide or command-line `ENABLE_USER_SCRIPT_SANDBOXING=YES` still wins over the target's setting, and Unity's own IL2CPP build phase fails under it too. The il2cpp-linemap uploaded is the one this build produced. Unity copies a map file into an "Append" export only when it changed, so an unchanged Append export into the same folder leaves this build's map there with the earlier export's time. At the end of an iOS/tvOS export the package therefore compares `LineNumberMappings.json`, `MethodMap.tsv` and `il2cppFileRoot.txt` in `Il2CppOutputProject/Source/il2cppOutput/Symbols` with the build's own output (`Library/Bee/artifacts//il2cppOutput/cpp/Symbols`): an equal file is current and gets a fresh modification time, and one that differs from it, or that this build did not write at all, and is older than the export is deleted (with the upload on: token set in the Editor's environment, `BUGSEE_NO_IL2CPP_MAPPING` and `BUGSEE_IL2CPP_MAPPING` unset; otherwise it is left alone). Only that folder is looked at, and nothing behind a link. The build's output folder counts only when one of its generated `.cpp` files is identical to the export's copy; where it is not found or does not match (another Unity layout, or a folder an earlier build left), or a link is in the way, or a file's time cannot be set, nothing is deleted and the export time is not given to the Run Script, which then uploads the map it finds without an age check (a warning says so when the upload is on). A `MethodMap.tsv` or `il2cppFileRoot.txt` beside the map that is older than the export is not sent with it: the Run Script uploads the map from a temporary folder holding only the current files. The pending-map pointer (`BugseePendingIl2CppLinemap.txt`) is recreated by every export, and the Run Script skips a map inside the project that is more than two minutes older than the export (`skip il2cpp-linemap ... older than this export`). A map named by `BUGSEE_IL2CPP_MAPPING` is used as given by the script when it is outside the project (inside it, the same age check applies) and is never deleted. Unity does not write `LineNumberMappings.json` unless the IL2CPP arguments ask for it; with none written the Run Script uploads no line map. Troubleshooting: an "Append" export after the IL2CPP arguments changed can make Unity list the GameAssembly target's Run Script phase twice, and `xcodebuild archive` then fails with "Unexpected duplicate tasks". This is Unity's own behaviour (it happens without the Bugsee package); the iOS export removes the repeated entry and logs it. A duplicate left by an earlier export is repaired by the next iOS export with this package version (Append or Replace). A tvOS export is not covered and keeps it: delete the repeated line from the GameAssembly target's `buildPhases` or export into a fresh folder (Replace). | Artifact | When | CLI type | |---|---|---| | `LineNumberMappings.json` + `MethodMap.tsv` (the package passes `--emit-source-mapping --emit-method-map` to IL2CPP for every IL2CPP build, token or not) | Android post-build; iOS at **Xcode build** (every configuration) | `il2cpp-linemap` | | Android `symbols.zip` / ELF | Android post-build | `elf` | | Android native libraries that still carry symbols (plugin and AAR libraries, see below) | Android post-build (APK/AAB) | `elf` | | ProGuard / R8 `mapping.txt` | Android post-build when present | `proguard` | | iOS `.dSYM` | Xcode Run Script (`Bugsee Upload Symbols`), every configuration | `dsym` | Failure policy: **never fail the Unity build**. Missing maps/UUIDs/CLI → warn and continue. #### Unwind data in Unity's `symbols.zip` (Android APK/AAB) Unity's `symbols//libunity.so`, `libil2cpp.so` and `libmain.so` (the files in `symbols.zip`) keep the symbol table and the build-id of the APK's library, but their code and unwind sections are empty placeholders (`SHT_NOBITS`): no `.eh_frame`, so the Breakpad file the server builds from them has no CFI. The Android minidump path (Android 11 and older; Android 12+ reports from the tombstone, which already carries the full stack) then stops unwinding after a frame or two inside `libunity.so`, before the C# frames. After Unity's zip is found, the Editor opens the built APK/AAB (the same ones used below), and for every library of the zip that declares an unwind section without bytes it copies the library's `.eh_frame` and `.eh_frame_hdr` from the archive's copy (same ABI, name and build-id, and the same address and size, otherwise it is refused) into a temporary copy of the zip under `Library/Bugsee/unwind-graft`, which is uploaded in place of the original and deleted afterwards. The result is one ordinary ELF with names and CFI. Measured with the s255 sample's libraries (arm64): `libunity.so` 6.3 MB -> 8.3 MB (2.0 MB zipped), 0 -> 44,884 `STACK CFI INIT` rules (`minidump_dump_syms`), the same lines as the APK copy gives; `libil2cpp.so` 12.1 MB -> 14.2 MB, 47,223 rules; `libmain.so` 10 rules. Checked on a device and on staging (Unity 6000.0.84f1, IL2CPP release, arm64, Samsung SM-T725 on Android 11, which reports through a minidump): the forced native crash (`native` scenario) before was 3 frames (`tgkill`, `Utils_CUSTOM_ForceCrash` in `libunity.so`, `il2cpp::vm::Runtime::Invoke`) and with the grafted zip is the full stack: `tgkill`, `Utils_CUSTOM_ForceCrash`, the C# method that crashed (`PumpPendingE2EFire`), `Runtime::InvokeWithThrow`, `Runtime::Invoke`, `scripting_method_invoke`, the Unity player loop up to `nativeRender`, and the Android runtime frames below (AU-263 against AU-302 in the AU staging app). The `abort` scenario (an ART abort raised from `InitJni`, entered from Java through ART's own stubs) still ends at `InitJni`: the frames above it are ART-generated code without unwind data, which this does not change. **The server keeps the first copy of a build-id at a level, so the grafted copy does not replace a symbol table of the same build-id that an earlier upload already stored** (the CLI reports `already on server at the same or better level, skipped`; the stored `libunity.so` of Unity 6000.0.84f1 had been uploaded without unwind data by an earlier build of the same app). A build-id that is new to the app gets the grafted copy; for one already stored, the test above had to use `bugsee-cli ... --type elf --force` (a wrapper around the CLI, via `BUGSEE_CLI_PATH`) to replace it. Until bugsee-cli and the server count unwind data as a better level, an app that already stored these libraries for a build-id without unwind data keeps the old copy (so no Android 11 and older minidump improvement for that build-id), unless the upload uses `--force`, which can also replace a DWARF copy. Android 12 and newer report from the tombstone and are not affected either way. Not done: an Export Project (no archive at export time) and the Gradle plugin's own upload of `native-debug-symbols.zip`; both still send Unity's copies as they are. Nothing fails the build: with no archive, no library that needs it, or any error, the zip is uploaded unchanged and a line says why. A library that is missing from the archive or does not match it (another build-id, address or size) is left exactly as Unity wrote it while the others of the same zip are grafted: the uploaded copy is then a mix, and the log names each library that was left alone, so those build-ids still lack unwind data. #### Native libraries beyond Unity's `symbols.zip` (Android APK/AAB) Unity's `symbols.zip` holds `libil2cpp.so`, `libunity.so` and `libmain.so` only. After it, the Editor looks at the other native libraries of the built app: the `.so` files of your own `Assets/Plugins/Android` folders and of the AARs that Gradle merged into the build (`//build/intermediates/merged_native_libs`, the folder before stripping; Unity keeps it under `Library/Bee/Android/Prj//Gradle`). A library is uploaded (`elf`, one more `bugsee-cli debug-files upload` call on a temporary folder under `Library/Bugsee/native-libs-upload`, deleted afterwards; its time limit grows with the size, 2 s per MiB over the usual 5 minutes, at most 30 minutes) when all of these hold: - it still has a symbol table (`.symtab` that names at least one function, object or TLS symbol, not just null, file and section symbols) or DWARF (`.debug_info`). The APK's copy is stripped by Unity 6's AGP (checked on 6000.0.84f1) but was not by Unity 2021.3's and 2022.3's AGP 4.0.1 / 7.4.2 builds checked, and on neither does the symbols server get a library from the APK: a crash frame in a library whose symbols were never uploaded stays a module and an offset; - it is the library the app contains: the same ABI folder, file name and GNU build-id as the entry in the built APK (every APK of Split APKs by target architecture, written beside the player path or in a folder of that name) or AAB, so a leftover of an earlier build in the intermediates folder is never sent; - its ABI is one of Player Settings' target architectures, and it is not already in Unity's zip (by ABI and file name, `.sym`/`.dbg` entries, also spelled `libfoo.sym.so`, counted: Unity 6's zip holds the plugin and AAR libraries as well, as symbol tables, so there is nothing more to send; Unity 2021.3's and 2022.3's holds the three Unity libraries only); - it fits the limits: 256 MB per library and 512 MB for the build (the smaller ones are kept first; a library left out is logged). **Not uploaded: libraries with dynamic symbols only.** All Bugsee libraries (`libbugsee-native.so`, `libbugsee-crashcp.so`, the crashpad libraries) ship stripped in the 7.4.2 AARs (`llvm-readelf`: `.dynsym`, no `.symtab`, no `.debug_info`; the copies in the AAR, the Gradle intermediates and the APK have the same build-id and size), as do most third-party AARs. This was not checked against the backend: whether a dynamic-symbols-only copy would let the worker name a few exported functions of such a library was not tested. It is left out because the symbols server keeps the first copy of a build-id at a given level, with the CLI labelling such a copy `symtab` (see Export Project above), so sending it could stand in the way of better symbols for that build-id. The consequence is plain: **frames inside the Bugsee libraries (and any other stripped library) stay unsymbolicated** (module and offset, or only the exported names a tombstone carries); symbolicating them needs symbols from the SDK team, not from the app build. The same rule is what AGP's `native-debug-symbols.zip` does for the Gradle plugin (it holds the libraries that have symbols), so the two paths send the same kind of file. With the Gradle plugin on (AGP 8.6+) the plugin uploads the same libraries from `native-debug-symbols.zip`, and a repeat of a build-id is answered as a duplicate. An Export Project build uploads none of this (Gradle has not run; the Bugsee Gradle plugin of the exported project, AGP 8.6+, or your own `bugsee-cli debug-files upload /build/intermediates/merged_native_libs/ --type elf --uuid --version --build ` call after your Gradle build does). `BUGSEE_NO_SYMBOL_UPLOAD` and a missing `BUGSEE_APP_TOKEN` turn it off with the other uploads, and a failure only logs a warning. What the build logs: `Bugsee: uploading N native libraries with symbols (...)`, or `Bugsee: no native library besides Unity's own carries a symbol table or debug info`. Verified (Unity 2021.3.45f1 Development and Release, 2022.3.62f3 Development, IL2CPP, arm64, Gradle AGP 4.0.1 / 7.4.2, `bugsee-cli` replaced by a logging stand-in, `BUGSEE_CLI_PATH`): a sample with a plugin library built with `-g` (`libbugseetest_dwarf.so`) and an AAR with one library stripped to its symbol table (`libbugseetest_symtab.so`) and one stripped to dynamic symbols (`libbugseetest_stripped.so`), each for arm64-v8a and x86_64 (the build targets arm64). Before: the elf upload was `symbols.zip` (`libil2cpp.so`, `libunity.so`, `libmain.so`) only. After (the same on all three builds): that zip, plus a second call on a folder holding `arm64-v8a/libbugseetest_dwarf.so` and `arm64-v8a/libbugseetest_symtab.so`; the stripped library, the x86_64 copies and the Bugsee libraries were not sent. On 6000.0.84f1 (Release, AGP 9.0.0) Unity's own zip listed `libbugseetest_dwarf.so`, `libbugseetest_symtab.so`, `libc++_shared.so`, `libswappywrapper.so` besides the Unity libraries and no second upload was made. Installed on an HONOR WOD-LX1 (Android 14) the 2021.3 build launched and a forced native crash (`nullrefnochk`) was recovered on the next launch. ### Windows Editor A `windows-latest` CI job (`windows-editor-path`) runs the Windows-relevant unit tests natively and `Tests~/WrapperPolicy/WindowsNativeSmokeTests.cs`, which resolve a stand-in `bugsee-cli.exe` (`Tests~/WindowsSmoke/FakeCli`) through the real file system (quoted, extension-less, lower-case-drive and forward-slash `BUGSEE_CLI_PATH`, a PATH with quotes and trailing backslashes, the cache layout) and launch it with `ProcessStartInfo.ArgumentList` for paths with spaces, UNC-path arguments, trailing backslashes, quotes, empty and non-ASCII arguments. That is .NET's `Process` on a Windows runner: not the Mono one in a Unity 2021.3 Editor, not the real CLI, not Unity, not a Gradle build. The rest of this section is what only a Windows Editor can confirm. Beyond that job, the Windows Editor path is covered by simulated tests only (`Tests~/WrapperPolicy/WindowsEditorPathTests.cs`, which run the CLI lookup with Windows separators, `;` PATH entries, case-insensitive de-duplication, `.exe` names, quoted and extension-less `BUGSEE_CLI_PATH`, drive-root, UNC and over-260-character cache paths, CRLF `--version` output and checksum files) and by reading the code; a Windows host (Windows 11 x64, Unity 2021.3.45f1) has run the checklist for the long-path items, see below and issues 212 and 252. The iOS Run Script is macOS-only by design: a Windows Editor exports an Xcode project whose script is POSIX text (LF only) and bakes no CLI path (that happens only in the macOS Editor); the script itself runs in Xcode on a Mac. Known limits that a Windows run should confirm or refute: - The Editor-side exclusion of build-tool folders (`Library`, `Temp`, `Bee`, `obj`) is judged on the part of the path below the scan root, so a project or build output that itself lives under such a folder (for example `C:\Users\me\AppData\Local\Temp\...` on a CI runner) is still scanned; folders with those names below the root are skipped (issue 124). The Windows CI job checks this against the runner's real temp path; a real Editor build under such a path is not verified. - Folders deeper than 260 characters (issue 212): the scans walk a build output one folder at a time (`DirectoryWalker`, issue 249): a folder that cannot be listed is named in a warning (`Bugsee: scan of : could not fully list the folder ...`) and the folders beside it are still scanned, and, on Windows, a file path of 260 characters or more is named once for its branch (the long-path retry below reads it). Links and junctions are followed, but a link that lists the same content as a folder above it, or whose name was already entered on the same path, is not entered again, which ends a loop on Mono 6.13 (it cannot resolve link targets); a walk stops after 100000 folders, folders deeper than 64 levels are not scanned (with a warning), and more than 20 folder warnings per scan are summarised. Among equally ranked files with the same modification time the shorter path is chosen (a stable tie-break; it usually, not always, prefers the spelling without a link). Observed on Windows 11 with the Editor's Mono 6.13 (Unity 2021.3, issue 252), `LongPathsEnabled` on and off alike: listing, stat and recursive enumeration work, but `File.ReadAllBytes` and `FileStream` throw `DirectoryNotFoundException`. The Editor therefore reads the APK/AAB, `symbols.zip`, native libraries and IL2CPP binaries through `BugseeLongPathFile`, which retries a failed open of a long Windows path through `CreateFileW` with the `\\?\` prefix. If the APK/AAB still cannot be read, the R8 mapping is not uploaded (it would be keyed by an id the app may not carry) unless `BUGSEE_BUILD_UUID` names the id. The Windows CI job (`WindowsNativeSmokeTests`) shows only that .NET 8 on a runner (which adds the `\\?\` prefix itself) enumerates, stats and passes a 300+ character file path to a child process, and it logs the runner's `LongPathsEnabled` value; it cannot detect the real risks. The long-path retry was run on that host (Unity 2021.3.45f1, real `bugsee-cli.exe`, a 251-character folder, `LongPathsEnabled` 0 and 1): no read warnings, and the line map, native library and mapping (under the app's own id) were uploaded. Still unconfirmed: the skip path on a real unreadable APK, Unity 2022.3 and 6, ARM64 Windows and the dashboard. - Process arguments go through `ProcessStartInfo.ArgumentList`; the Unity 2021.3 `System.dll` quotes them with the standard `PasteArguments` rules (read from its IL, not run on Windows), so spaces, quotes and trailing backslashes in paths should survive. - The quote and extension-less forms of `BUGSEE_CLI_PATH` are understood by the Editor's lookup only. The Gradle plugin block of an Android Export Project and the CLI child process read the raw value, so there such a value is ignored (the plugin falls back to its own lookup); use a plain full path to `bugsee-cli.exe` when you export a Gradle project. - `bugsee-cli.exe` is found as `.exe` only; a `.cmd` or `.bat` wrapper is not looked up. Manual checklist for a Windows machine (Unity 2021.3.45f1 or 2022.3 LTS with Android Build Support, `BUGSEE_APP_TOKEN` set to a staging or test app token in the Editor's environment, `BUGSEE_ENDPOINT` if not production): 1. No CLI anywhere (not on PATH, nothing in `%LOCALAPPDATA%\Bugsee\bin`, no `BUGSEE_CLI_PATH`): build an Android IL2CPP release with Create symbols.zip. Expect the Console to log `Downloading bugsee-cli 0.8.1 for x86_64-pc-windows-msvc` (`aarch64-pc-windows-msvc` only on a native ARM64 Windows Editor; the x64 Unity 2021.3 and 2022.3 Editors run emulated on ARM64, report X64 and get the x64 build, which runs there), `Using bugsee-cli 0.8.1 (downloaded): %LOCALAPPDATA%\Bugsee\cache\cli\0.8.1\\bugsee-cli.exe`, then the mapping and ELF uploads with exit 0, and the symbols to appear in the dashboard. A second build must say `cached download` and not download again. 2. With `BUGSEE_NO_CLI_DOWNLOAD=1` and no CLI: expect one warning naming `install.ps1` and the paths tried, and the build to succeed. 3. Install with `powershell -ExecutionPolicy ByPass -c "irm https://download.bugsee.com/cli/install.ps1 | iex"`, restart the Hub and Editor without touching PATH: the build must find `%LOCALAPPDATA%\Bugsee\bin\bugsee-cli.exe` (`install directory`). 4. `BUGSEE_CLI_PATH` as `"C:\Program Files\x\bugsee-cli.exe"` with the quotes, and as `C:\Program Files\x\bugsee-cli` without `.exe`: both must resolve in the Editor's own uploads. Then repeat with an Android Export Project and note which CLI the Gradle plugin uses (expected: its own lookup for the two odd forms, your path for a plain full path). 5. Build into a folder with a space (`C:\Build Output\My Game\game.apk`), then one under a 250-character path, then one under `%TEMP%`: record which uploads are found (the last is expected to be found, since only folders named `Library`, `Temp`, `Bee` or `obj` below the scan root are skipped, see above). For the 250-character case, run it with `LongPathsEnabled` on and off (restart the Unity Editor, and the Hub if it launched it, after changing the value, since Windows reads it once per process) and record, for each scan (mapping, symbols zip, `libil2cpp.so`, native libraries, IL2CPP module identity), whether the Console shows a warning, shows nothing, or the upload happens, and whether `bugsee-cli.exe` reads the file (issue 212). 6. Export an iOS project from the Windows Editor: `BugseeScripts/upload-symbols.sh` must contain no `\r` and `BAKED_CLI=''`. ### Player Settings checklist **Android** 1. Scripting Backend: **IL2CPP** is the supported configuration for fully symbolicated native crashes. With Mono, frames inside the Mono runtime (`libmonobdwgc-2.0.so`, `libmono-native.so`, `libMonoPosixHelper.so`) cannot be symbolicated: Unity 2021.3 has no Mono ARM64 (ARMv7 only) and those libraries have no GNU build-id. Frames in `libunity.so` and `libmain.so` still symbolicate. A Mono Android build logs a one-time warning at build time (whether or not symbol upload is configured) and is never failed. A Mono build that is not a Development Build ships no `.pdb`, so its managed frames have IL offsets only (`[0x0000b] in :0`) in the app; the Editor has `bugsee-cli` convert the portable `.pdb` files to a BMF mapping and upload it so the dashboard shows C# file:line (see "Mono Release: BMF mapping from portable PDBs"), and warns when it cannot (no token or `BUGSEE_NO_SYMBOL_UPLOAD`: once; also a missing compiler folder, a stale or missing `ManagedStripped`, a too-old CLI, a failed upload). 2. Create symbols.zip / native debug symbols enabled 3. For primary LNM apply: native debug symbol level **FULL** (DWARF lines), not SYMBOL_TABLE-only 4. No custom Gradle templates needed: Bugsee patches the generated Gradle project (the Bugsee Gradle plugin with `ndk { enabled = true }` when it pins AGP 8.6+, i.e. Unity 6; on older AGPs, see below); a template of your own that pins another AGP major than your Unity's default fails the build and is reported (file layouts the patching understands: [Gradle file layouts](#gradle-file-layouts)) 5. **Minify** (R8) may be enabled for Release and Debug with no extra setup: the package appends its keep rules (`Plugins/Android/bugsee-unity-wrapper.proguard`) to the generated `unityLibrary/proguard-unity.txt` on every Android build, because Unity does not read that file from a package. The rules keep the wrapper classes C# looks up by name over JNI (`UnityWrapper`, `UnityManagedException`) and the SDK interfaces implemented from C#. They sit between `# bugsee:proguard begin` / `end` markers and are replaced, not duplicated, on the next build. They also drop R8's "Missing class" errors for three platform classes the Android SDK references but older compile jars lack (`android.telephony.satellite.SatelliteManager`, `SatelliteStateChangeListener` and `android.app.ApplicationStartInfo`): Unity 6's proguard template no longer has `-ignorewarnings`, so without them a Minify build with Target API Level 34 or 35 stops in R8. If you add your own JNI code, keep its classes in your Custom Proguard File ### Gradle file layouts Unity 2021.3, 2022.3 and 6000.0.84f1 generate and read only Groovy files (`*.gradle`): the editors' `GradleTemplates` folders hold no `.kts` file and the Android extension assembly of all three knows no `.kts` name (checked 2026-10-17), so a `launcherTemplate.gradle.kts` dropped into `Assets/Plugins/Android` is not used. Kotlin DSL files exist only when your project converts the generated Gradle project in its own `IPostGenerateGradleAndroidProject` step (run it with a `callbackOrder` below 10 so the package patches the converted files). The package edits what is there, in whichever DSL, and never fails the build over the Gradle plugin step. Dependencies, `mavenCentral()` and the plugin step are separate: | File shape | Result | |---|---| | Unity's Groovy layout (root `plugins { }`, launcher `apply plugin: 'com.android.application'`), also with custom base/launcher/settings/main templates that keep those lines | Root `id 'com.bugsee.android.gradle' version '...' apply false`, launcher `apply plugin:` after the AGP line (checked on Unity 2021.3, 2022.3 and 6000.0.84f1) | | Root declares AGP with `buildscript { dependencies { classpath } }` and no `plugins { }` | The plugin becomes a root `classpath` entry (and `mavenCentral()` is added to the buildscript repositories if missing), the launcher applies it | | Kotlin DSL files (`build.gradle.kts`, `settings.gradle.kts`), `libs.versions.toml` aliases (the `libs` catalog only, entries in `[plugins]` as inline or `[plugins.name]` tables, camelCase and dashed names) | The launcher's `plugins { }` block gets `id("com.bugsee.android.gradle") version "..."` after the AGP entry and `bugsee { ndk { enabled.set(true) } }` follows the block; the AGP version for the 8.6 check is read through `gradle/libs.versions.toml` (default location only) | | `pluginManagement { repositories { ... } }` in settings whose repositories serve the plugin through none of `gradlePluginPortal()` (or its `plugins.gradle.org/m2` URL), Maven Central, or a proxy whose `content { }` filter includes `com.bugsee` and `com.bugsee.android.gradle` (an `exclusiveContent` filter that does not include them does not count) | `mavenCentral()` is appended after the existing entries, so a mirror you list first keeps priority, with a warning saying what was added and why (same for a root `buildscript` repositories block that needs it). Set the environment variable `BUGSEE_NO_GRADLE_REPO_INJECTION` (any value) to forbid changing repositories: the plugin is then not applied and the warning lists the lines to add. A `pluginManagement` whose repositories are written in a shape the package cannot read (all on one line, or `repositories {` on the outer brace's line) is treated the same way: the plugin is not applied, with the lines to add | | Plugin you declared yourself (`id`, `apply plugin`, `classpath`) | Kept as written, nothing is added next to it | | Launcher that applies `com.android.application` with `apply` (no `plugins { }` block), a one-line `plugins { }`, a plugins block without AGP | Left alone. A warning (on every build) names the lines to add, for the shape of the project's root: for a launcher `plugins { }` block, `id("com.bugsee.android.gradle") version ""` (Groovy: `id '...' version '...'`) after the AGP entry and `bugsee { ndk { enabled.set(true) } }` below the block; for a launcher that uses `apply`, two edits, which depend on the root: with a root `plugins { }` block, the same `id(...) version ... apply false` line there and `apply(plugin = "com.bugsee.android.gradle")` after the AGP line (plus `configure { ndk { enabled.set(true) } }` for NDK support); with a root `buildscript { }` block, `classpath("com.bugsee:bugsee-android-gradle-plugin:")` in its dependencies (and `mavenCentral()` in its repositories) plus the same apply line. These manual forms are not run by the package. The plugin is never applied ahead of AGP: it looks the AGP extension up while being applied and would silently do nothing | | AGP below 8.6, version unreadable (computed, catalog elsewhere) | No plugin; see the next section. An unreadable version gets a warning with the same lines, and Bugsee > Android > Force Gradle Plugin On Older AGP (unsupported) applies it regardless | Verified with real Unity 6000.0.84f1 APK builds (Mono ARMv7, Gradle 9.3.1 / AGP 9.0.0; a scratch `IPostGenerateGradleAndroidProject` at order 0 reshaped the generated files): converted `.kts` root, launcher and settings; the same with a `libs.versions.toml` alias root; a Groovy root with `buildscript { classpath }`; settings whose `pluginManagement` lists only `google()`. All four built and their APKs carried the plugin's `assets/bugsee_build_id.properties`. The previous package version, on the same projects, applied no plugin to the Kotlin files (one warning) and failed Gradle on the other two (`Plugin with id 'com.bugsee.android.gradle' not found`, `Plugin [id: 'com.bugsee.android.gradle', version: '4.0.8', apply: false] was not found in any of the following sources`). Limits, not fixed: the structure scanner works line by line, so Groovy slashy strings (`/.../`) and quotes nested inside a GString interpolation are not understood; files the package rewrites are written without a byte order mark; the release `debugSymbolLevel` edit looks for a single `release {` line and can pick `signingConfigs { release {` in a launcher that has one. A `bugsee { }` block you wrote yourself is kept and never replaced (the package's own is the one ending in `// bugsee:gradle-ndk`), and a `pluginManager.apply(...)`, `apply(plugin = ...)`, `id(...)` or `classpath` of the plugin counts as your own declaration. A regular expression in a repository content filter that cannot be read, or does not finish within half a second, makes the filter count as not serving Bugsee (an include filter does not match, an exclude filter does), so `mavenCentral()` is appended with its warning. Kotlin launcher on AGP below 8.6: the build id asset task is Groovy code and is not added to a `.kts` file; the SDK derives its own build id. The release `ndk { debugSymbolLevel }` the package adds on 2021.3 is written in the launcher's own DSL. ### Export Project (Android) An Export Project build leaves Gradle for later (Android Studio, or `gradlew` on a CI machine), so at export time there is no R8 mapping, no `symbols.zip` and no native library for the Editor to upload (it logs "no Android symbols.zip / libil2cpp.so found"). On AGP 8.6+ (Unity 6) the Bugsee Gradle plugin is applied to the exported launcher, but it reads the app token only from its own `bugsee { appToken(...) }` DSL, from `/bugsee.properties` (`app_token=`) and from the manifest, never from `BUGSEE_APP_TOKEN`, and a Unity app has the token only at runtime (`Bugsee.Launch`). Its mapping, native and build-info tasks therefore logged `Bugsee: Could not resolve appToken. Skipping ...` (checked on 6000.0.84f1, plugin 4.0.8, with `BUGSEE_APP_TOKEN` set in the environment). For an Export Project the generated launcher's `bugsee { }` block now reads the token when Gradle runs: ```groovy bugsee { if (System.getenv('BUGSEE_NO_SYMBOL_UPLOAD') == null && System.getenv('BUGSEE_APP_TOKEN')) { appToken(System.getenv('BUGSEE_APP_TOKEN')) } if (System.getenv('BUGSEE_ENDPOINT')) { endpoint = System.getenv('BUGSEE_ENDPOINT') } if (System.getenv('BUGSEE_CLI_PATH') && new File(System.getenv('BUGSEE_CLI_PATH')).isFile()) { cliPath = System.getenv('BUGSEE_CLI_PATH') } ndk { enabled = true useMergedNativeLibs = false } } ``` (The Kotlin DSL form is the same in Kotlin syntax.) **No token is written to any file of the exported project**: the lines name an environment variable, so the project can be committed or shared. Build it with `BUGSEE_APP_TOKEN` set in the environment of the Gradle process: from a terminal (`BUGSEE_APP_TOKEN=... ./gradlew assembleRelease`), or in CI. Android Studio uses the environment it was started with (on macOS an app opened from the Dock does not see shell variables; start it from a terminal that has the variable, or run Gradle from a terminal); that case is not verified here. The Gradle user home is not consulted: the plugin reads `bugsee.properties` only from the root project, and putting the token there stores it in the project. Without the variable the plugin skips as before; `BUGSEE_NO_SYMBOL_UPLOAD` (any value) turns it off as for the Editor's uploads. `BUGSEE_ENDPOINT` (a URL such as `https://api.bugsee.com`: the plugin's build-info request needs the scheme) and `BUGSEE_CLI_PATH` (the path of an existing file; a relative path, a directory or a bare command name is ignored without a message and the plugin downloads its own `bugsee-cli`) are passed on the same way. The plugin also registers a build record for the release variant (build info; size analysis stays off); `plugin.buildInfo.enabled=false` in the root project's `bugsee.properties` turns that off. What the exported project's Gradle build then uploads (real Unity 6000.0.84f1 export, Gradle 9.3.1 / AGP 9.0.0, `bugsee-cli` replaced by a logging stand-in so nothing was sent): the R8 `mapping.txt` with the launcher icon under the build id the APK carries; the native symbols in AGP's `build/outputs/native-debug-symbols/release/native-debug-symbols.zip` (`useMergedNativeLibs = false`): Unity's own symbol tables of `libil2cpp.so`, `libunity.so` and `libmain.so` (Unity's `setupSymbols.gradle` copies the full ones into it; same build id as the unstripped libraries in `unityLibrary/symbols`) and the AAR libraries that carry symbols; and the build-info registration. Why not the default (the `merged_native_libs` directory): it holds Unity's **stripped** copies of those three libraries (dynamic symbols only, same build id). `bugsee-cli` 0.8.1 labels such a library `symtab`, and the server keeps the first copy of a build id at a given level (a same-level copy is answered as a duplicate and the CLI exits 0), so sending the stripped ones first would block the real symbol tables from any later upload (read in the CLI and server code, not run against the server). Limits, not fixed: - At Player Settings' Public level the symbol tables give function names, not file:line; IL2CPP file:line needs the Debugging level and the line map. An export writes no IL2CPP line map at export time (the Editor uploads nothing then); get it as described for the line-number mapping above and upload it with `bugsee-cli debug-files upload --type il2cpp-linemap`. - Bugsee's own native libraries (`libbugsee-native.so`, `libbugsee-crashcp.so`, the crashpad libraries) ship **stripped** in the AAR (only `.dynsym`, checked with `llvm-readelf`), so an app build has nothing to upload for them. - On AGP below 8.6 there is no plugin, so the exported project's Gradle build uploads nothing; use `bugsee-cli` on its output. - The token is not safe from logs: Gradle with `--info` or `--debug` prints the `bugsee-cli` command line, which contains `--app-token `, in the console and in the daemon log under `~/.gradle/daemon`; the token is also in the CLI's arguments (visible in `ps` while it runs) and in the CLI process's environment. Do not run CI builds of the export with `--info`/`--debug`, or mask the value. `plugin.debug=true` in `bugsee.properties` or `debug = true` in the DSL logs it too, and if the plugin falls back to its own uploader it logs the token when the server calls it invalid (plugin 4.0.8, `SymbolUploader`). These are plugin behaviours, not changed by this package. - If the launcher has a `bugsee { }` block of your own (for example from a template), the package does not edit it and the Editor warns at export with the lines to add; without them the plugin skips. Builds the Editor runs itself are unchanged: the block keeps its token-less form, because the Editor's own upload (after Gradle) already sends the mapping and the full `symbols.zip`. With the token enabled for those builds as well (tried), the plugin would repeat the Editor's mapping (same file, same id), register a build record from every release build, and send its native upload first: the stripped libraries of the merge step, which (as above) can then block the Editor's symbol tables of the same build ids. ### Unity 2021.3 and 2022.3 (no Bugsee Gradle plugin) Both ship AGP 7.4.2 / Gradle 7.5.1; Gradle plugin 4.0.8 needs AGP 8.6+ / Gradle 8.7+ and fails to load there (checked on 2022.3.62f3: `NoClassDefFoundError: KotlinCompilerPluginSupportPlugin`, then `NoSuchMethodError` on `OutOperationRequest.toListenTo`). What it does for a Unity app, and what stands in for it: | Gradle plugin function | Unity 6 with AGP 8.6+ (6000.0.84f1 has AGP 9.0.0; 6000.0.1-44 on AGP 8.3.0 gets the block, not the plugin) | Unity 2021.3 / 2022.3 (AGP 7.4.x), Unity 6000.0.1-44 (AGP 8.3.0) | |---|---|---| | Declare `bugsee-android`, `bugsee-android-ndk` | Package (Maven injection) | Same | | `assets/bugsee_build_id.properties` = UUID of the R8 mapping (the id the SDK reports) | Plugin | The package adds the same asset task to the launcher (`GradleBuildIdBlock`), for AGP 7.4.x and 8.0 to 8.5 (7.0 to 7.3 and older get no block). With R8 off, or no block, no asset is written and the SDK derives its own id | | `com.bugsee.android.BUILD_UUID` manifest meta-data (fallback id when R8 is off) | Plugin | Not added: the SDK derives `UUID(token, versionName, versionCode)` itself when it finds neither; the uploads use that id (`AndroidBuildUuid`) when the built app has no asset | | Mapping upload (`--uuid`, `--icon`) | Package Editor upload (the plugin finds no app token in a Unity build, so its own upload skips; an Export Project is the exception, see [Export Project](#export-project-android)) | Same, keyed by the id read back from the built APK/AAB's asset (never assumed from the build script), else the SDK's synthesized id with a warning; launcher icon attached | | Native symbol upload | Package Editor upload of Unity's `symbols.zip` (same reason) | Same | | NDK enabled | Plugin | Not applicable: the NDK artifact is declared and the Editor uploads the symbols | | Bytecode instrumentation (OkHttp, HttpEngine, `android.util.Log`, thread, main-thread misuse, operation dispatch, Compose, startup tracing), SDK-extension provider stripping, Compose compiler plugin | Plugin | **Not recovered** (needs AGP 8.6+). They act on the app module's own JVM bytecode, which in a Unity app is a launcher stub, so little is lost, but a Java/Kotlin plugin of yours that uses OkHttp or `HttpEngine` is not auto-captured on these Unity versions | | Build-info / size-analysis upload, dependency and timing collection | Plugin (skips, no token) | **Not recovered** | The mapping upload of an Android build is keyed by the id the built app reports: the APK/AAB's `bugsee_build_id.properties` if it has one, else (when `BUGSEE_BUILD_UUID` is not a UUID) the id the SDK derives from token, version name and version code (from the generated launcher, which is what the APK carries; a `versionNameSuffix` or version code changed outside Unity's generated launcher can still differ, and then a mapping uploaded under the derived id will not match; only the asset avoids that). The native upload uses the same id unless `BUGSEE_BUILD_UUID` is set, which keys it as before (any non-empty value); for the mapping `BUGSEE_BUILD_UUID` is used only when the app carries no asset and the value is a UUID, and never overrides the app's own id. The asset block is added on AGP 7.4.x whenever the build is Android, token or not (like the Unity 6 plugin, which is applied regardless); `BUGSEE_NO_GRADLE_BUILD_ID=1` stops the package adding it (and removes an earlier one) and leaves only the derived id. Its Groovy classes are compiled by Gradle for every build, and the part that runs per variant is guarded so a failure there only costs the id; a tokenless 2022.3 release build with R8 on was run to check they do not break Gradle (see the matrix). With the derived id, a rebuild with the same token, version name and code but different R8 output re-uses the id: the server keeps the first mapping uploaded under it, so bump the version code for a minified build whose obfuscation changed. With Split APKs by target architecture the id is read from every APK; if they disagree (or only some carry one) the build warns and the upload uses the synthesized id. A launcher that overrides the version code per output (`versionCodeOverride`, what Unity's split version-code setting adds) is not trusted for the synthesized id's version code: Player Settings' is used. Verified with real IL2CPP arm64 builds (staging token set, `bugsee-cli` 0.8.1, uploads to UNITYTA; the generated launcher's Gradle ran AGP 7.4.2 / Gradle 7.5.1 on both): | Unity | Build | R8 | Result | |---|---|---|---| | 2022.3.62f3 | release | off | builds; no asset (nothing to match), game assets intact (24 `assets/bin` entries), no mapping uploaded, native symbols uploaded | | 2022.3.62f3 | development | off | same | | 2022.3.62f3 | development | on | builds; APK asset id equals the uploaded mapping id | | 2022.3.62f3 | release | on | same, plus emulator native, Java and managed crashes symbolicated | | 2022.3.62f3 | release | on, `BUGSEE_NO_GRADLE_BUILD_ID=1` | builds; no asset; mapping uploaded under the synthesized id with the warning; the Java crash on an emulator grouped with the symbolicated issue | | 2022.3.62f3 | release, Split APKs by target architecture (ARMv7 + ARM64) | on | builds; Unity writes a folder `split.apk/` of per-ABI APKs: both carry the same asset id, equal to the uploaded mapping id; the symbols zip (named after `split`, not `split.apk`) is found and uploaded | | 2022.3.62f3 | release, no app token | on | builds; the block is added regardless and the asset is in the APK; no upload, no warning | | 2022.3.62f3 | Export Project | on | builds; no native libraries exist in the export, so no ELF upload (the CLI refuses a directory upload without `--uuid`, which every ELF upload now carries; checked with `bugsee-cli --dry-run`) | | 6000.0.84f1 | release APK (Gradle 9.3.1, AGP 9.0.0) | on | with `BUGSEE_APP_TOKEN` set and a logging stand-in as `BUGSEE_CLI_PATH` (nothing uploaded): the plugin's mapping, native and build-info tasks logged `Could not resolve appToken. Skipping` and made no CLI call; only the Editor's three uploads (il2cpp-linemap, mapping, `symbols.zip`) ran. Unchanged by this package change | | 6000.0.84f1 | Export Project, then `assembleRelease` of the export | on | Before: the same `Skipping` lines. Now: `uploadBugseeReleaseMapping` called the CLI for `mapping.txt` (+ icon, the APK's build id), `uploadBugseeReleaseApk` packed and registered the build, `uploadBugseeReleaseNative` called it once for `native-debug-symbols.zip` (`.sym` of libswappywrapper, libc++_shared, libmain, libil2cpp, libunity; the stripped `merged_native_libs` directory, 21 libraries, is not sent because of `useMergedNativeLibs = false`); no token in any `.gradle`, `.properties`, `.json`, `.xml` or `.txt` file of the project (only Unity's player data file that already carries it, and its build copies). Without `BUGSEE_APP_TOKEN`, or with `BUGSEE_NO_SYMBOL_UPLOAD=1`: `Skipping` and no CLI call, build succeeds | | 2021.3.45f1 | release | off, development off | builds, as above | | 2021.3.45f1 | release, development | on | builds; APK asset id equals the uploaded mapping id | Unity 6000.0 early releases (6000.0.1 to 6000.0.44) ship AGP 8.3.0 / Gradle 8.4 per Unity's compatibility page (6000.0.45-60: AGP 8.7.2 / Gradle 8.11, 6000.0.61-78: 8.10.0 / 8.13, 6000.0.79-84: 9.0.0 / 9.1.0, 6000.0.85+: 9.1.1 / 9.3.1); those editors are not installed here, so their layouts are not checked in. The package adds the block, not the plugin, on AGP 8.0 to 8.5 (a log line says which AGP the project pins). The block was run, outside Unity, on a real 2022.3.62f3 Export Project with the AGP swapped in the root and a minified release assembled by standalone Gradle (JDK 17): AGP 8.0.2 / Gradle 8.0.2, 8.3.0 / 8.4 and 8.5.0 / 8.7 all built, the APK's `bugsee_build_id.properties` equalled the MD5-name UUID of `mapping.txt` and every game asset was intact; that, plus the 7.4.2 runs below, is the evidence for the gate (7.4.x and 8.0 to 8.5); it is not a Unity 6000.0.1-44 editor build, which is not installed. Not verified: a Unity editor on AGP 8.0 to 8.5 end to end, Unity 2021.3 releases with AGP below 7.4, AAB output (its mapping upload is verified, see above; not the build id asset inside the bundle), build with Gradle configuration cache (the block avoids `Task.project` at execution time but was run without it), and Windows/Linux Editors. When Minify is on and the upload found no usable mapping (none, or an empty one), the Editor logs one warning (the build is never failed): Java and Kotlin frames lose their line numbers and, for classes R8 may rename, their names in Bugsee (the wrapper and SDK classes are kept by their rules, so on a real device their names stay and only the line numbers go: `UnityWrapperProvider.java:1` instead of `:240`). It lists the folders searched and the manual call, `bugsee-cli debug-files upload --type proguard --version --build ` with `BUGSEE_APP_TOKEN` set. For an APK or AAB the mapping's age is not judged (Unity copies Gradle's file with its modification time, and an up-to-date R8 task leaves it unchanged); in an Export Project a `mapping.txt` older than the build was left by an earlier Gradle run (Unity never runs Gradle there), so it is not uploaded and the warning names it. Where the mapping lands (real builds with R8 on, identical on Unity 2021.3.45f1, 2022.3.62f3 and 6000.0.84f1): an **APK** and an **AAB** get `_mapping.txt` beside the output, copied from Unity's Gradle project (`Library/Bee/Android/Prj//Gradle/launcher/build/outputs/mapping//mapping.txt`), so both upload as usual (when Gradle wrote none, Unity logs its own "Failed to copy mapping file" error and the package warns too); an **Export Project** has none, because Unity does not run Gradle for it: build the exported project with Gradle and upload `launcher/build/outputs/mapping//mapping.txt` yourself (the warning says so on every such build; on AGP 8.6 and later the exported project carries the Bugsee Gradle plugin, which uploads it itself when it has the app token, and a second upload is harmless). With the upload off (no `BUGSEE_APP_TOKEN` in the Editor, or `BUGSEE_NO_SYMBOL_UPLOAD`) a Minify build whose mapping exists gets one log line with the same call; a missing mapping is not reported then, as nothing was going to be uploaded. Releases built without R8 (Minify off, the Unity default) have no mapping and no Java names to restore. Minify may be turned on with no extra setup: the package appends its keep rules to the generated `unityLibrary/proguard-unity.txt` on every build (see the Player Settings checklist above), so `UnityWrapper` and `UnityManagedException` survive R8 and the SDK launches. **iOS** 1. Scripting Backend: IL2CPP 2. Nothing to enable for LineNumberMappings: the package adds `--emit-source-mapping --emit-method-map` to the IL2CPP arguments of every IL2CPP build, with or without `BUGSEE_APP_TOKEN` in the Unity Editor's environment (`IL2CPP_ADDITIONAL_ARGS` of the Editor process for the build only; Player Settings are not edited). The export therefore has `LineNumberMappings.json` and `MethodMap.tsv`, and the Xcode Run Script (step 4) uploads them when the token is only in the Xcode or CI environment 3. Build or archive in Xcode: the Run Script uploads the dSYMs of the configuration being built. Debug has a dSYM only with `DEBUG_INFORMATION_FORMAT = dwarf-with-dsym` (Unity exports Debug as `dwarf`); without one the script prints a warning and uploads no dSYM 4. Ensure `BUGSEE_APP_TOKEN` is visible to the Xcode Run Script phase. The token is read when Xcode builds, never written into the exported project (which you may commit). A build started from the Xcode GUI does not see your shell's environment, so provide it one of these ways. Prefer the environment: the CI / Xcode Cloud environment, `export BUGSEE_APP_TOKEN=...` before `xcodebuild`, or `launchctl setenv BUGSEE_APP_TOKEN ...` (visible to a GUI-launched Xcode after it restarts). A plain environment variable is not printed into the build log. Or add a user-defined build setting named `BUGSEE_APP_TOKEN` to the Unity-iPhone target (Xcode exports build settings to Run Script phases as environment variables); that value is stored in the Xcode project, so do not commit the project after adding it. A Unity export in Replace mode regenerates `project.pbxproj`, so that setting (and an `.xcconfig` attached to the target) is lost and must be added again after each export; the package does not add one. Xcode prints build settings, including one from an `.xcconfig` or from `xcodebuild ... BUGSEE_APP_TOKEN=...`, into the build log, so such a log holds the token. An app token also ships inside the built app, so it is not a secret of the same order as a signing key, but do not publish the log. Without it an archive prints `warning: Bugsee: BUGSEE_APP_TOKEN unset` (a build that is not an archive prints `note:` instead) and nothing is uploaded - The script reports problems as `warning:` lines in the Xcode build log and issue navigator, and always exits 0 (it never prints `error:`, and rewrites the `error:` of the CLI's own output to `error -`, because Xcode fails an archive whose log has an `error:` line even when the script exits 0): a missing token, `bugsee-cli` not found, no dSYM, and a failed upload with the CLI's exit code in words (21: the server rejected the token; 30: server error; 31: network; 1/2: unexpected error or argument mismatch) 5. The iOS export sets `DEBUG_INFORMATION_FORMAT=dwarf-with-dsym` on every configuration of Unity-iPhone and UnityFramework, so Debug builds have a dSYM too. `dsymutil` on UnityFramework adds time to each Debug build; to keep Unity's own setting, tick **Bugsee → iOS → Keep Xcode Debug Info Format (skip dSYM force)** or set `BUGSEE_NO_DSYM_FORCE` in the Editor's environment (CI) ### Uploading the mapping from a later CI job The build writes the mapping next to the generated C++ even without a token. Keep it as a build artifact and upload it after the build: | Platform | Where the files are | |---|---| | Android | `_BackUpThisFolder_ButDontShipItWithYourGame/il2cppOutput/Symbols/` (keep this folder; the Editor's `Library/Bee` copy is overwritten by the next build) | | iOS, Unity 2022.3 and 6000 | `/Il2CppOutputProject/Source/il2cppOutput/Symbols/` | | iOS, Unity 2021.3 | `/Classes/Native/Symbols/` | ```sh bugsee-cli debug-files upload /LineNumberMappings.json \ --type il2cpp-linemap --version --build \ --uuid ``` `MethodMap.tsv` and `il2cppFileRoot.txt` next to the JSON are sent with it. `il2cppFileRoot.txt` is written by Unity itself (observed on Android; the package does not write it; whether an iOS export contains it was not checked here, the iOS upload script sends it when it is beside the map) and is not required: on staging the worker resolved the same frames with and without it for Unity's flat IL2CPP output (issue #208; a project with duplicate source file names was not tested). The UUIDs are those of the IL2CPP module: for Android the GNU build-id of each `libil2cpp.so` (one per ABI, comma separated; `llvm-readelf -n` from the NDK on the APK's `lib//libil2cpp.so`, or the copy in `symbols.zip`), for iOS the Mach-O UUID of `UnityFramework` from the Xcode build (`dwarfdump --uuid` on the built `UnityFramework.framework/UnityFramework` or its dSYM; the export itself has no binary). Version and build must match the build's. Upload the matching native symbols (`elf` / `dsym`) as well. On iOS, the injected Run Script does all of this on its own when `BUGSEE_APP_TOKEN` is in the Xcode environment, so a manual upload is only for builds without it. ### IL2CPP handled exceptions: what resolves (issue #263) Frames that stay `... () (<00000000000000000000000000000000>:0)` on the dashboard are not a lost mapping upload. Measured on one HONOR WOD-LX1 (Android 14), Unity 6000.0.84f1, SDK 7.4.2, staging app AU, with the sample scenario `nullref`: an uncaught `NullReferenceException` on a coroutine, which Unity routes through its log handler to the wrapper's exception pipeline and which is reported as a handled error (`Bugsee.LogException` of a thrown exception was not exercised). The il2cpp-linemap and `libil2cpp.so` of each exact build were uploaded (linemap uuid = build-id of that build's `libil2cpp.so` = the `moduleUUID` the player sent). IL2CPP stack trace information was the project default (method names only, no "Method Name, File Name, and Line Number", sample `ProjectSettings` does not set it); with file and line information the text itself carries file:line (Mode A) and none of this applies. | IL2CPP build | What the wrapper sent | Dashboard frame | |---|---|---| | **Development**, Create symbols.zip Debugging | no `address` on any frame (the player's `il2cpp_native_stack_trace` returned zeros for both frames); the text says `[0x00000] in <0000...>:0` | unresolved (`<0000...>:0`) | | **Release**, Create symbols.zip **SymbolTable/Public** | `address` + `moduleUUID` on every frame (the throw-site address lies inside `MoveNext` of the same build's `libil2cpp.so`, checked with `llvm-nm`) | unresolved: the uploaded ELF has function names but no line table | | **Release**, Create symbols.zip **Debugging** (`Bugsee > Android > Use Full Native Symbols`, or `BUGSEE_ANDROID_FULL_SYMBOLS=1`) | same | resolved: `NullRefE2E.cs:96` (and `Coroutines.cs:17` for the engine frame) | Reading of the table: in a Release IL2CPP build without IL2CPP line information, C# file:line for these exceptions needs Debugging symbols plus the il2cpp-linemap. The zero native IPs in the Development build were observed on 6000.0.84f1; the likely reason is that a Development IL2CPP build builds its trace from stack-frame tracking instead of a native walk, which was not confirmed in Unity's source. Because there is nothing to resolve from, switching a Development build to Debugging symbols does not help; use a Mono Development build, or enable IL2CPP line information. The build warning for Public and Disabled symbols names the managed-exception consequence only for an IL2CPP Release build whose IL2CPP line information is known to be off. **What resolves, checked on staging on 2026-11-18** (Unity 6000.0.84f1, Android SDK 7.6.0 for the Android results, real uploads for each exact build): Release IL2CPP with Debugging symbols plus the il2cpp-linemap, for a build id with no earlier Public upload, resolves handled and `NullReferenceException` frames to file:line on Android (HONOR WOD-LX1, Android 14); Mono Release with the Portable PDB BMF resolves (Samsung SM-T725, armv7, bugsee-cli 0.9.0); iOS Release IL2CPP resolves (iPhone XS, iOS 18.7.9). The table above and the measurement paragraph before it are Android-only and were measured earlier on SDK 7.4.2 (the Development row on 6000.0.84f1); only the results listed here were taken on 7.6.0. Not tested: other devices, Unity versions and iOS Development builds. **Known limitations, with their conditions.** - **Development builds.** On Android (observed on 6000.0.84f1) they send no addresses, so a frame resolves only where Unity's own stack text carries file and line. A frame without one, for example a coroutine throw site, stays `<0000...>:0`. - **Public, then Debugging, for the same build id.** Public and Debugging builds of the same code share the `libil2cpp.so` build id. On staging, after a first upload with Public symbols, a later upload of the Debugging symbols for the same build id was not enough for events to resolve: the CLI logged `upgraded SYMBOL_TABLE -> FULL` and one ELF record remained, but events received minutes later stayed unresolved, although the device sent the right address and module UUID and the same frame resolved locally against that Debugging ELF with the worker's linemap code. The device side was correct; the cause is not known and is an open backend investigation (#263). Decide the Create symbols.zip setting before the first upload of a build; when switching afterwards, change the code and check that the `libil2cpp.so` build id differs before and after; a new build id is expected to avoid the trap, which was not tested. - **Release IL2CPP native crashes.** On the Android 11 minidump path they resolved on staging (one device, Samsung SM-T725). On the Android 12+ tombstone path (checked on Android 14) frames in `libil2cpp.so` can stay raw addresses although the symbols are `ready` and the frame's build id and `rel_pc` are right (they resolve locally); managed events resolved against the same uploaded ELF minutes earlier. This is an open backend investigation (see #263), not a promise either way: Debugging symbols do not guarantee native crash file:line for Release IL2CPP on Android 12+. - **Group page.** The dashboard issue page shows the frames of the issue's first event, so a group that began with an unresolved event keeps showing `<0000...>:0` while later events of the group are resolved (the per-event `crash.json` has `trace-sym`); the group key appears to come from the unresolved frame text. Worker side. ### Script Debugging vs dSYM - **Script Debugging** / IL2CPP stacktrace information controls managed stack quality. LineNumberMappings.json and MethodMap.tsv come from the IL2CPP arguments the package adds for every IL2CPP build (not from Script Debugging), with or without `BUGSEE_APP_TOKEN`: the files are written so that a later CI job can upload them; the upload needs the token. `BUGSEE_NO_SYMBOL_UPLOAD` turns the upload off only (the files are still written). Set `BUGSEE_NO_IL2CPP_MAPPING` to turn the emission and the upload off, or `BUGSEE_IL2CPP_MAPPING` to upload a file you made yourself (the arguments are still added for the build). The arguments are passed through the Editor process's `IL2CPP_ADDITIONAL_ARGS` environment variable for the build only (Player Settings and `ProjectSettings.asset` are not touched). They add `//` comments, with absolute source paths, to the generated C++ (the player binary is unchanged but its build-id differs from a build without them) and a few MB of mapping per build (`MethodMap.tsv` is about 190 bytes per method); the first build after upgrading, and every toggle of `BUGSEE_NO_IL2CPP_MAPPING`, recompiles all generated C++ once. Set `BUGSEE_NO_IL2CPP_MAPPING` if you hand the generated C++ or an Xcode export to others. Unity 2022.3 and 6000 also add `--emit-source-mapping` themselves when Cloud Diagnostics crash reporting is on; the package does not add a flag your Additional IL2CPP Arguments or `IL2CPP_ADDITIONAL_ARGS` already has. For an Android Export Project, Unity writes the `IL2CPP_ADDITIONAL_ARGS` value as one Gradle argument (Unity 6 and 2021.3 were verified: `:unityLibrary:buildIl2Cpp` then fails with `unknown arguments`; 2022.3 has the same Gradle writer but was not run), so right after Unity generates the module the package rewrites the `commandLineArgs.add("--emit-source-mapping --emit-method-map")` line in `unityLibrary/build.gradle` (or `.gradle.kts`) into one `add` per option. If it cannot split a line safely it logs a warning; if your own post-processing regenerates that file afterwards, keep each option on its own line. - **dSYM / ELF** carry native line programs used for the primary LNM remap (native PC → C++ file/line → C#). - You need **both** the linemap upload and native symbols with line info for viewer C# file/line on native fatals. ### Managed stacks: MethodMap vs LNM file/line - ExceptionPipeline / `LogException` send **UnityManagedException** JSON (`frames[].trace`, optional `frames[].address`, `moduleUUID`, nested `cause`, `signature`, `buildID`). - On IL2CPP, `frames[].address` comes from **`il2cpp_native_stack_trace`**, which IL2CPP fills in the same loop as the managed trace (newest frame first, one IP per frame). The printed text can have fewer lines than IPs: `[StackTraceHidden]` throw helpers (`ExceptionDispatchInfo.Throw`) are native frames with no text, and earlier throws are printed as segments after a rethrow through `ExceptionDispatchInfo` or an await (`--- End of stack trace from previous location ---`). Only the **live segment** (after the last separator) is paired, anchored at the bottom (oldest text frame with the oldest IP); the hidden frames are at its top. Earlier segments, and a live segment longer than the IP list, get no address, so the throw site of an exception that was rethrown through an await has none (names still go through MethodMap; the worker only applies a line when the method at the address matches the frame). Verified on an iPhone XS (iOS) and an arm64 emulator (Android), Release IL2CPP, Unity 2022.3.62f3: sync, `throw;`, `throw ex;`, delegates, coroutines, inner and aggregate exceptions and a synchronous throw in the first part of an async method are fully paired (separator-free, equal counts); `ExceptionDispatchInfo.Throw` and await shapes pair the live segment only (every attached address resolved, with the dSYM / unstripped libil2cpp.so, to the method in its frame text). IL2CPP prints an async method by its own name, not as `d__1.MoveNext`; two segments joined without a separator were not seen. A frame whose text has a C# line above 0 (IL2CPP with a usym file; `in :LINE` too) gets none: its IP is a line-table address, not a return address. A usym entry with line 0 prints like a build without usym and cannot be told apart. Addresses are never read out of the stack text of a thrown exception; Mono builds send none (Mono's `<0xSTART + 0xOFFSET>` is a method start). The Unity log path (`FromUnityLog`: reached only when Unity's text is the only copy, e.g. another log handler replaced Bugsee's without chaining, a failed or skipped `Report`, or a `LogType.Exception` message with no exception object; a normal `Debug.LogException` or an uncaught exception, coroutines included, takes the throw path above) has no native IPs and no way to tell which image a number in the text belongs to, so it sends no address either; its frames are symbolic (method names, and the file:line a usym entry printed). - **Known limitation: an async exception rethrown through await (IL2CPP).** When an exception is thrown inside an `async Task` continuation and rethrown where it is awaited, `Exception.StackTrace` has two parts joined by `--- End of stack trace from previous location where exception was thrown ---`. When the separator is printed (it is omitted in some shapes, see the previous bullet), the frames before it get no `address` and stay unresolved in the default method-names-only configuration (name only, `... () (<00000000000000000000000000000000>:0)`; with IL2CPP line information the text itself carries file:line, see Mode A above); only the frames after it, the live rethrow stack, resolve. This is by design: the native addresses of the earlier throw are not available when the report is made (IL2CPP keeps only the text of that part), and a guessed address would produce a wrong file:line, which is worse than none. Evidence (printed-separator shape only; the fixture and staging issues are external to this repository, from a manual device run): staging IUTA-80, fixture scenario `fx-async` (`RunHandled` awaiting `AsyncThrow`, which throws in its continuation), iPhone XS, Release IL2CPP, Unity 2022.3.62f3: 18 frames, 6 before the separator (including the throw site `Sync` and `AsyncThrow`) unresolved, 12 after it resolved (`RunHandled` to `FixtureFrames126.cs:87`, `AsyncThrow` to `:49`, the line of its call to `Sync`). The pairing itself (no address before the separator) is the rule verified on both platforms in the previous bullet; the dashboard result of this IUTA-80 shape was observed on iOS only, as one data point, and was not checked on Android. Related known case, backend line lookup, being fixed outside this repository: the entry stub frame of an `async void` method has no source markers in the line map and can resolve to a neighbouring method's line (IUTA-72, `RunHandled` shown at `:78`) (a backend limitation, not something the SDK can change). - The payload's `cause` (from `InnerException` and `AggregateException`) is sent as a nested object of the same shape: `name`, `reason` (the plain message), `frames[]`, `moduleUUID`, optional `cause`; at most 8 exceptions per payload, outermost first, aggregate siblings linearized after each other, and at most 256 K characters in total (the first exception is always kept whole; a cause that would pass the cap, and those after it, are dropped). Measured: staging accepted a 1 MB reason JSON from an Android device, so the cap is not a server limit; it stops a chain of exceptions with huge messages from multiplying a report's size. This is the contract the worker change will consume; today the worker ignores it. Unity's `JsonUtility` drops a field of its own class, so each level is serialized without it and the chain is joined by `ManagedPayloadJson`. - **Address contract:** every address the SDK pairs to a frame of a thrown exception (`FromException`) is a hex **return address, module-relative** (instruction pointer minus the load address of the image that holds the IL2CPP code, subtracted by IL2CPP itself: UnityFramework on iOS, libil2cpp.so on Android; 32-bit values are zero-extended), resolved against the `moduleUUID` sent with the exception (that same image's Mach-O UUID / GNU build-id). For a thrown exception the SDK never sends absolute addresses; the Unity log path (`FromUnityLog`) sends none. The worker subtracts 1 to land in the calling instruction. - Release IL2CPP walks the native stack, so a method the C++ compiler inlined into its caller has no frame of its own: the managed trace (and Android/iOS payloads alike) can lack the throw-site method even though the C# line is recoverable from the caller's address via the dSYM inline chain (done by the worker, not the SDK). - Worker: MethodMap demangles mangled names; when addresses + symbols + linemap match, **primary LNM** remaps to C# file:line. The SDK sends module-relative offsets (see the address contract above), which the worker uses as is. - **`moduleUUID`** is the UUID of the IL2CPP image the player is running (GNU build-id of `libil2cpp.so`, Mach-O UUID of UnityFramework), read at runtime through `il2cpp_native_stack_trace` (from a throwaway thrown exception, probed at launch and kept once found), so it is the UUID of that very build for thrown exceptions, exceptions that were never thrown, and exceptions read from the Unity log alike. A Development build that breaks on all exceptions in a debugger stops once at that probe's throw. It is empty when it cannot be known (Mono, Editor), which the worker treats as missing. No build step writes it into the project: the UUID of a build exists only after the player is built, and an earlier package version's `Assets/Resources/BugseeIl2CppModuleUuids.txt` was therefore one build stale; that file is no longer read and can be deleted. The worker still accepts a CSV. ## Known issues (7.0.0-beta.1) - **Handled managed exceptions in a Release IL2CPP build on Android without IL2CPP line information, with Public symbols (symbol table only),** stay unsymbolicated; use Debugging symbols plus the il2cpp-linemap. Development builds send no addresses on Android. See "IL2CPP handled exceptions: what resolves (issue #263)". - **Public, then Debugging, for the same `libil2cpp.so` build id** may keep frames raw on the dashboard (open, under investigation, #263); see the same section. - **iOS, next launch after a launch that died before the app became active:** the next launch may block the main thread for up to about 8 seconds while the crash report is uploaded. The fix is in the native iOS SDK (bugsee-cocoa PR #351, not yet released). Unity launches normally do not hit it, because the SDK starts while the app is active; the opt-in iOS native early launch starts the SDK before the app is active, so an app that uses it can hit this. ## Field validation (S1 / S2) Prerequisites (tooling + optional build-dir scan): ```bash Tools~/scripts/validate-field-symbols.sh Tools~/scripts/validate-field-symbols.sh /path/to/unity/build/output ``` Device/CI proof remains manual. ### Milestone S1 — iOS C# file/line 1. IL2CPP iOS build with LineNumberMappings generated. 2. `BUGSEE_APP_TOKEN` set for Unity export + Xcode archive env. 3. Archive; confirm Run Script uploads dSYM + `il2cpp-linemap` (UUID from `UnityFramework`). 4. Trigger a native fatal (`Bugsee.TestCrash` / signal) with `DetectAndReportCrash`. 5. Viewer shows **C# file/line** on the crashing frames; wrong/missing map leaves native frames intact. ### Milestone S2 — Android C# file/line 1. IL2CPP Android build; Create symbols.zip / **FULL** native debug symbols. 2. NDK enabled (`bugsee-android-ndk:7.6.0` + Gradle `ndk { enabled = true }` on Unity 6+). 3. Post-build uploads `elf` + `il2cpp-linemap` (multi-ABI UUIDs). 4. Native fatal on device; viewer shows **C# file/line**. ### Milestone C1 — managed auto-capture / LogException 1. `CaptureManagedExceptions` enabled (default). 2. Unhandled managed exception / `LogUnhandledException` appears once (no dual-hook duplicates). 3. **Mode A:** MethodFileLineNumber / Mono Development build → viewer shows C# file:line from stack strings. 4. **Mode B (in progress):** Release IL2CPP + uploaded dSYM/ELF + `il2cpp-linemap` → `LogException` on a **thrown** exception emits native IPs for worker LNM. Validate on device before treating as parity with Sentry. 5. **Mode C:** MethodMap demangles mangled names when module UUID(s) match (names only if no addresses/lines). Managed error/crash **grouping** (one signature per event, Unity-primary when strong): [exception-signatures.md](exception-signatures.md). ### Managed view hierarchy (the Unity scene in a report) The native SDK asks the wrapper for the Unity scene (`requestData("vh")`) when it takes a report snapshot and when `Bugsee.CaptureViewHierarchy()` runs, and waits 500 ms from when the request returns (a later reply is ignored; on iOS three late replies in a row cut the wait to 50 ms until the next capture start). The wrapper keeps the main-thread cost small and the answer on time: - **Main thread: only the read of Unity objects.** Names, component types, instance ids, `RectTransform` corners, `Renderer.bounds` and camera projections cannot be read off the main thread. They are copied into plain arrays in short slices of at most 5% of a frame, one slice per frame (60 Hz: 0.83 ms; when the game's real frames are longer than the display's, 5% of those, at most 5 ms). Over the 250 ms the walk may run that is about 5% of the time, so a large scene is read only in part and comes back `truncated`; the budget is the constant `ManagedViewRequests.FrameShare`. A scene is therefore read over several frames, so an object that moves is not captured at one instant. - **Worker thread: everything else.** Building the tree, the secure-rectangle test, string escaping, the JSON and the reply run on a thread-pool thread (on Android the reply attaches that thread to the JVM for the call; on iOS the completion export is called from it: the SDK claims a reply atomically and accepts it on any thread). The main thread never waits for it. - **Deadlines counted from the request.** The walk stops taking nodes at 250 ms, the write stops at 350 ms (the JSON is complete, with `truncated: true` on the nodes that were cut), and a timer answers `null` at 400 ms if nothing was sent, also when the main thread is stalled. The 400 ms is a target, not a guarantee: the timer and the worker run on the shared thread pool, so a pool the game has saturated can delay both, and the SDK then ignores the late reply (and on iOS counts the timeout). On iOS an in-time `null` counts as an answer, so it does not start the 50 ms silent mode. - **One capture at a time.** A request made while one runs joins it and gets the same JSON. Pausing the app (a manual report opens a native screen) reads the rest of the walk at once, still within its deadline, and the worker finishes the capture; quitting answers it `null`. A scene loaded or unloaded during the read marks the tree `truncated`; objects destroyed during it are skipped. - **iOS keeps the old behaviour for a tiny scene.** The SDK's timer starts when the request returns, so a snapshot of at most 48 nodes that the first slice completes is written and answered inside the request. - On iOS, after three late replies in a row the SDK waits only 50 ms until the next capture start, which a scene of more than 48 nodes cannot meet; the wrapper's in-time `null` at 400 ms is what keeps that from starting. - The tree is still capped at 1500 nodes and depth 24, and the payload is unchanged. ### Secure rectangles: coordinate origin `Bugsee.AddSecureRectangle(RectInt)` and `RemoveSecureRectangle(RectInt)` take screen pixels with the origin at the **top-left** of the screen, y growing downward. This is what both native SDKs expect (Android `Rect` in display pixels; iOS points with a top-left origin, which the wrapper derives by dividing by the screen scale). The wrapper passes the rectangle through as given and does not flip it. Unity's `Screen`, `Input.mousePosition` and `Rect` from screen-space APIs use a **bottom-left** origin, so convert before adding: ```csharp // Unity screen rect (bottom-left origin) -> rect for AddSecureRectangle (top-left origin). static RectInt ToSecureRect(Rect unityScreenRect) { int x = Mathf.FloorToInt(unityScreenRect.xMin); int y = Mathf.FloorToInt(Screen.height - unityScreenRect.yMax); int w = Mathf.CeilToInt(unityScreenRect.xMax) - x; int h = Mathf.CeilToInt(Screen.height - unityScreenRect.yMin) - y; return new RectInt(x, y, w, h); } ``` A `RectTransform` corner from `GetWorldCorners` in a screen-space overlay canvas is also bottom-left: build the `Rect` from those corners, then convert. Rectangles are not flipped, scaled or moved on rotation or resize; rectangles are keyed by their exact left/top/right/bottom, so when the screen size changes remove the old rectangle (or call `RemoveAllSecureRectangles()`) before adding the new one. ### Secure rectangles in Unity screen space `Bugsee.AddSecureScreenRectangle(Rect unityScreenRect, int displayId = 0)` and `RemoveSecureScreenRectangle(...)` take what Unity's screen space gives you (bottom-left origin, `Screen.width` x `Screen.height` pixels: `Input.mousePosition`, or `RectTransform.GetWorldCorners` of a Screen Space - Overlay canvas; `RectTransformUtility.PixelAdjustRect` is canvas-local and needs converting first) and do the conversion for you: the y flip, the scale of each axis from Unity's render size to the native surface (Android Resolution Scaling, any `Screen.SetResolution` including another aspect, iOS render scale), and the surface's position (Android: Unity's SurfaceView, the one whose buffer has `Screen`'s size, on the screen; iOS: Unity's view on the screen). The result is rounded outwards and clamped to the surface. Contract: - The rectangle is remembered as a **fraction of the screen it was added for**, and converted again, within a frame, when the screen size or the surface position changes. It follows Resolution Scaling, a moving surface and any layout that scales with the screen. - It does **not** know your layout. After a rotation, or any change that does not scale proportionally (fixed-size or anchored UI), call `RemoveSecureScreenRectangle` with the values you added and add the new rectangle. - Remove with exactly the values that were added (a rectangle recomputed from floats can differ in the last bit and then removes nothing). Adding the same rectangle twice needs two removals, for `AddSecureRectangle(RectInt)` too. NaN is ignored with a warning. - Screen-space calls are always queued and take effect on the next frame, in call order with each other and with `RemoveAllSecureRectangles()`. - If the surface cannot be read, the last surface read is used, or the display's full size if none was read yet; a warning is logged once per state change. - `displayId` 0 is the main display and the only one verified on devices. For another id the rectangle is in `Display.displays[id]` rendering space and is converted with the display's system size and no offset; whether the native SDKs ask for that display's rectangles was not verified. A display that does not exist registers nothing and logs a warning; a negative id throws. - Not verified on a device: a nonzero surface offset (status bar, cutout, multi-window), iPad Split View / Stage Manager, and that the SDK's masking blanks the region (the registered rectangle was compared with the rendered content). **Limitation of `AddSecureRectangle(RectInt)`:** the rectangle must already be in the native display's coordinate space; the wrapper does no scaling or offsetting beyond the iOS points conversion. With Android Resolution Scaling or `Screen.SetResolution`, or a non-fullscreen Unity view (status bar or notch offset), `Screen.height` and pixels differ from native pixels, so scale or offset the rectangle yourself, or use `AddSecureScreenRectangle`. On iOS the wrapper divides by `UIScreen.scale`, which is wrong if the render size differs from points x scale. A rectangle is removed with the same top-left rectangle it was added with. `Bugsee.GetAllSecureRectangles()` returns the rectangles added with `AddSecureRectangle(RectInt)` and not yet removed, as `RectInt[]` in the top-left-origin pixels they were registered with (normalised: an inverted rectangle comes back with its corners in order), in no particular order, empty when none. Each distinct rectangle is listed once; one added several times disappears only after as many removals as adds. Rectangles added with `AddSecureScreenRectangle` are not returned. The wrapper answers from its own list: it gives the native SDKs its rectangles through its own provider rather than their `addSecureRectangle`, so the SDKs' own `getAllSecureRectangles` is empty here and is not read. ### Network filter and the default sanitizer On Android and iOS a filter set with `Bugsee.SetNetworkEventFilter` (on Android also one declared in the manifest) turns the SDK's built-in redaction off: `Authorization` and `Cookie` headers, `token` query values and `password` body fields (and on Android `user:password@` URL credentials) are recorded as is unless the filter redacts them. Call `Bugsee.ApplyDefaultNetworkSanitizer(event)` first in the filter to keep the built-in redaction, then add your own: ```csharp Bugsee.SetNetworkEventFilter(e => { // SDK defaults, in place. If it could not run (false), drop the event rather than record it unredacted. if (!Bugsee.ApplyDefaultNetworkSanitizer(e)) return null; e.Url = e.Url.Replace("/internal/", "/x/"); return e; }); ``` It returns true when it ran and false in the Editor (no SDK there). Inside the filter it needs nothing else. On Android, an event you built yourself (`Bugsee.GetExchangeFactory()`, or your own `INetworkEvent`) is sanitized through a native copy that the SDK hands out only while it is launched with network capture on, so outside that the call redacts nothing and returns false: check the result. On iOS the wrapper copies the event into a native `BugseeNetworkEvent`, runs `+[Bugsee defaultNetworkSanitizer]` on it (stateless, needs no launch) and writes back only the fields it changed. The redaction rules are each SDK's own: measured on iOS SDK 7.0.1, the sanitizer redacts `token` query values (to ``), `Authorization` and similar headers and JSON `password` fields, but it leaves `user:password@` URL credentials, which the Android one removes; do not rely on it for those. A failure inside the SDK is logged and also returns false. ### WebView secure views An app that embeds a WebView plugin can keep its content out of the video with `Bugsee.AddSecureWebView(handle)` and `Bugsee.RemoveSecureWebView(handle)`. Pass the plugin's native handle: the `android.webkit.WebView` as an `AndroidJavaObject` on Android, the `WKWebView*` as an `IntPtr` on iOS (typed overloads; a plugin that does not expose its native handle cannot use them). They return false for a null or zero handle, for an object of another class (a plain view) and in the Editor. - **Android:** calls `Bugsee.addSecureWebView` on the UI thread (the SDK measures the view's geometry on the calling thread) and waits for it. The SDK buffers a registration made before launch. It does not survive `Stop()`: register again after a relaunch. - **iOS:** the SDK's `+addSecureWebView:` alone does not hide the view (it protects secure areas inside the page), so the wrapper also calls `+addSecureView:`, which masks the view in the video, as Android's call does. The work runs on the main queue. The SDK masks a view only while it is launched, unlike Android: a call made before the launch finished has no effect on the video, so call it once `Bugsee.IsLaunched` is true. `RemoveSecureWebView` calls `+removeSecureView:`, which also lifts a mask the app set on the same view itself; the page-level protection stays, harmlessly. The pointer must be a live Objective-C object: another class is refused, a stale or non-object pointer is undefined. Limits: it marks a native view, so it does nothing for a page drawn into a Unity texture (use `AddSecureRectangle` for that) and nothing while the Android Unity frame pusher is the capture source (it does not know native views, see below). ### Native APIs that are not exposed Decided in #103 against the Android 7.4.2 and iOS 7.0.0-beta7 public APIs (re-checked against the iOS 7.0.0 headers: these are unchanged; the wrapper channel's timestamped `log` is new and not wired, see the CHANGELOG): - `+[Bugsee logError:]` (iOS `NSError`): an `NSError` can only come from native code, which already calls the SDK directly; Unity code has `Bugsee.LogException`. Android has no counterpart. - `+[Bugsee showVideoCapturePreview]` / `hideVideoCapturePreview` (iOS): a developer diagnostic of the SDK's own capture, with no Android counterpart; it shows nothing about the Unity pipeline, which pushes its own frames. - The `requiresFiltering` overload of `addNetworkEvent`. (The one of `log` is exposed as `Bugsee.Log(message, level, requiresFiltering)`, #190.) Network events from `Bugsee.AddNetworkEvent` already go through the wrapper channel with filtering on, so the network half needs nothing. ## Native dependencies - **Android:** Maven `com.bugsee:bugsee-android:7.6.0` + `com.bugsee:bugsee-android-ndk:7.6.0`, declared in the generated Gradle project by `Editor/BugseeAndroidMavenDependencies.cs` (Gradle plugin `4.1.1`, patched into the generated project when it pins AGP 8.6+). Native symbols for upload come from Unity's `symbols.zip` (Player Settings > Publishing Settings > Create symbols.zip). Unity 6 defaults it to Disabled and Public holds symbol tables only; native/IL2CPP file:line symbolication needs Debugging, which is necessary but not shown to be sufficient: Release native crashes stayed unresolved on staging even with it (#263; see the section *IL2CPP handled exceptions*) (about ten times larger, mind Google Play's limits). The build warns when a Bugsee app token is set and the level is not Debugging; `Bugsee > Android > Use Full Native Symbols (Debugging) For Symbol Upload` (or `BUGSEE_ANDROID_FULL_SYMBOLS=1`) builds with Debugging and restores the setting. On 2021.3 release builds also get `debugSymbolLevel 'FULL'`. Core publishes no transitives; NDK is a separate artifact and must be declared. Fragment secure-view overloads are typed as `Object`, so Unity JNI does not need `androidx.fragment`. - **iOS:** SPM-only. Xcode resolves [`bugsee/spm`](https://github.com/bugsee/spm) `7.1.0` (iOS 15+). C bridge: `Plugins/iOS/BugseeUnityBridge.mm` + `BugseeUnityCallbacks.mm`. ### Feedback (in-app chat) `Bugsee.Feedback` (`ShowFeedbackUi`, `SetDefaultGreeting`, `SetListener`) drives the native Feedback add-on. It is off by default: the add-on is a separate native module on both SDKs, and the wrapper links it only when you ask, so an app that does not use it carries no chat code. To turn it on, add the scripting define `BUGSEE_FEEDBACK` to Player Settings > Other Settings > Scripting Define Symbols for Android and/or iOS, or set the environment variable `BUGSEE_FEEDBACK=1` for the build (CI), and rebuild. Then: - **Android:** `com.bugsee:bugsee-android-feedback:7.6.0` is declared in the generated `unityLibrary/build.gradle` next to the core and NDK artifacts. The AAR needs Android Gradle plugin 8.1.1 or newer (it pulls Material 1.13 and `androidx.dynamicanimation` 1.1.0) and compileSdk 35 or newer (`androidx.compose.ui` 1.8): Unity 2021.3 and 2022.3 generate AGP 4.0.1 to 7.5.0, and an older Target API Level gives an older compileSdk, so the export refuses the define with that reason instead of failing later in Gradle; use Unity 6 with Target API 35 or newer. If the project declares the Bugsee SDK itself, the export warns that the Feedback line was not added. The wrapper registers the extension itself on first use, because the Bugsee Gradle plugin strips the AAR's own registration provider and, in the Unity 6000.0.84f1 build checked, its replacement was not injected. A project that declares the artifact itself (EDM4U, a custom template) needs no define. - **iOS:** the Xcode export links the `BugseeFeedback` product of [`bugsee/feedback-spm`](https://github.com/bugsee/feedback-spm) (same version as the core package, iOS 15+) into `UnityFramework`; it registers itself with the SDK at load. It is not linked next to a local core package (`BUGSEE_IOS_SDK_LOCAL_PACKAGE`): the add-on builds against the published core, and the export says so. The chat is native UIKit/SwiftUI/Android UI shown over the Unity view. Where the define is read: Player Settings (Scripting Define Symbols) for the platform, and on Unity 6 the active build profile's defines; a define passed only through `BuildPlayerOptions.extraScriptingDefines` is not seen. The environment variable is read by the Editor process while it exports the build, not by a later Gradle or Xcode run. An Append export into an existing Xcode project with the switch off removes the `feedback-spm` link, including one added by hand; keep the define on, or link the package in a target of your own. Without the add-on, each of the three calls does nothing and the wrapper logs a warning once per process saying how to enable it. In the Editor the calls also do nothing and log once. `SetListener` callbacks (`OnNewMessagesReceived`, `OnNewMessageSent`) arrive on the Unity main thread. The Feedback appearance properties (`IAppearance`) are independent of this switch; they only affect a Feedback UI that is present. ### iOS native early launch (opt-in) By default Bugsee starts when C# calls `Bugsee.Launch`. To start it natively at app launch set, for the export, `BUGSEE_IOS_EARLY_LAUNCH=1` and `BUGSEE_IOS_APP_TOKEN=`, optionally `BUGSEE_IOS_EARLY_LAUNCH_OPTIONS=` (same keys as the C# options, e.g. `{"com.bugsee.option.detect.hang":true}`; the export stores them in Info.plist with `$` written as `\u0024`, because Xcode would collapse `$$` in plist strings and drop internal keys such as the endpoint); or use **Bugsee > iOS > Early Launch...** (an Editor preference, per machine; the variables win). The export writes them into the app's Info.plist (the token is in the app bundle either way). Nothing is written when it is off. **Consent and privacy: with this on, the iOS SDK starts before any C# code runs, so before any consent check of yours, and even if your app never calls `Bugsee.Launch`.** Do not turn it on if Bugsee must wait for user consent. The native start happens after Unity's own `didFinishLaunching` returns (before the first scene). The SDK installs its crash handler at once; per the Bugsee iOS docs it defers the real session until the app becomes active. The first `Bugsee.Launch` then adopts the running session: no second launch, the `Launching`/`Launched` lifecycle events are delivered once (also when they fire after the adopting call), and the managed capture hooks are installed as usual. Options are launch-only: those passed to `Bugsee.Launch` that differ from the early options are logged as a warning and not applied (put them into the early options); a different token is logged too and the session keeps the build-time token. After `Stop`, `Launch` works as without early launch. `RelaunchedAfterCrash` is not delivered for an early session. It does nothing on the Simulator. Verified on an iPhone 16 Pro (iOS 27.2): with Bugsee running in the process, the Crash Report Extension files a launch-watchdog kill (`0x8badf00d`) and a foreground jetsam kill as crashes without a recording, on the next launch. Without early launch these kills are normally not reported in a Unity app. Coverage starts only after Unity's `didFinishLaunching` returns, so a crash or kill inside it is not covered, and nothing is filed with a debugger attached. ### iOS Crash Report Extension (launch watchdog and out-of-memory kills) On iOS 27+ devices the iOS SDK can report what no in-process handler survives: a foreground memory kill (jetsam, a "Foreground Out of memory" crash), a background memory kill (a non-fatal error) and, when Bugsee was already launched in that process, the launch watchdog (`0x8badf00d`, a "Main thread locked" crash). In Unity, Bugsee starts when your C# code calls `Bugsee.Launch`, which happens after iOS's launch watchdog window. Launch-watchdog kills (`0x8badf00d`) are therefore normally not reported. Out-of-memory kills (foreground = crash, background = non-fatal error) and exits after `Bugsee.Launch` are reported. Nothing is filed for a process in which the app did not call `Bugsee.Launch`. In the dashboard these issues currently show the summary "Application process exited"; the specific kind (Main thread locked, Foreground Out of memory, Background Out of memory) is in the description and attributes, not in the kind-specific titles the Bugsee iOS doc lists. That needs a Crash Reporter Extension target next to the app. The iOS export adds it for you (`Editor/BugseeIosCrashExtensionPostProcess.cs`): an ExtensionKit target `BugseeCrashReport` (bundle id `.BugseeCrashReport`, iOS 27.0 deployment target on the extension only) linking the `BugseeCrashExtension` product of `bugsee/spm`, embedded in the app. Its source is the two documented lines (`import BugseeCrashExtension` and `@main struct CrashReport: BugseeCrashReporterExtension {}`). The app keeps linking `Bugsee`. Reports are sent on the next launch; there is no SDK option, and `DetectAndReportCrash` / `DetectAndReportExit` must stay at their defaults. **When it is added.** Only when all of these hold; otherwise the export logs why and carries on unchanged, and it never fails the build: - the build machine has Xcode 27 or newer (`xcodebuild -version`; older Xcode cannot build the target); - the setting is not Off. Default **Auto** adds it only in an interactive Editor build with Player Settings *Automatically Sign* on and a team id, because the extension needs an App Group and a manual (often wildcard) provisioning profile cannot carry one. Auto stays off in batch mode (`-batchmode`, CI): scripted archives and exports often sign without `-allowProvisioningUpdates`, with a manual profile or fastlane match, and the new entitlement would break them; the log says how to enable it. **On** adds it for any signing setup (then register the App Group on both App IDs yourself); **Off** never adds it. Set it with the menu **Bugsee > iOS > Crash Report Extension** (an Editor preference, per machine, not per project) or the environment variable `BUGSEE_IOS_CRASH_EXTENSION` (`auto`, `1`/`on`, `0`/`off`; the variable wins, and is the way to set it on CI); - the iOS SDK package is the published one (a local package must declare `BugseeCrashExtension`), and the project has no crash-reporter extension of its own (an app can have only one). **App Group.** Default `group.`; override with `BUGSEE_IOS_APP_GROUP=group.your.id` (or `BugseeIosCrashExtensionPostProcess.AppGroupOverride` from a build script). The export adds the `com.apple.security.application-groups` entitlement to the app (it creates `Unity-iPhone.entitlements`, or extends the file the target already names) and to the extension, and writes the id into the extension's Info.plist as `BugseeAppGroup`. **Bugsee only removes an App Group it added itself.** The files it added the group to are listed in the extension's Info.plist (`BugseeAppGroupAddedTo`, next to `BugseeAppGroup`; Xcode and codesign ignore the key); a group your app's entitlements already had (for a widget, say) is never removed, whether the extension is turned off, the bundle id (hence the derived group) changes, or the export is appended. A project exported by an earlier package version has no such list, so nothing is removed from it. Automatic signing registers the group and the extension's App ID only when Xcode itself builds the project, or `xcodebuild` runs with `-allowProvisioningUpdates`; otherwise (and with manual signing) register `group.` and `.BugseeCrashReport` in the Apple Developer portal and add a profile for the extension. The extension's signing style follows the app target's. The export checks at its end that the app's entitlements list the group (it warns if not), but a plugin that runs after it and replaces the app's `CODE_SIGN_ENTITLEMENTS` (for example `ProjectCapabilityManager` with its own file) can drop the group again. **Versions.** The extension's `CFBundleShortVersionString` and `CFBundleVersion` are set to the app's at export time (`MARKETING_VERSION` / `CURRENT_PROJECT_VERSION` on the extension target); if you change the app's version after export (for example a CI script bumping the build number), change the extension's too, or App Store validation fails. **Append exports.** Exporting into an existing project keeps the target and refreshes what follows the app (bundle id, version, build, team, signing style); if the extension is no longer wanted (setting Off, older Xcode, batch mode with Auto) the target, its embed entry, files and the App Group on the app are removed, so the project always matches the current settings. An app can have only one crash-reporter extension; a project that already has one of its own is left alone (with a warning). **Unity and iOS 27.** Building with Xcode 27 links the iOS 27 SDK; Unity 2021.3 / 2022.3 players then abort at launch on iOS 27 (the UIScene lifecycle is required for apps built with this SDK). The extension only helps on a Unity version, or with a UIScene shim, that runs on iOS 27. **Simulator.** The extension is never run in the Simulator and the project still builds for it. Test on a device with iOS 27 without the debugger (launch from the Home Screen). ### iOS bridge status Wired: Launch/Stop, blackout, log/trace/event, exceptions (JSON-in-reason), TestCrash, report/upload (+ labels), identity (`SetUserIdentifier` / `GetUserIdentifier` / `ClearUserIdentifier`; there is no email API), attributes, secure rects, appearance colors/strings, feedback (opt-in, see [Feedback](#feedback-in-app-chat)), network/log/breadcrumb filters, report handler (via `BugseeWrapper`), lifecycle listener (via wrapper `onLifecycleEvent` → `Bugsee.LifecycleEvent` / `ILifecycleEventListener`). ### iOS managed exceptions by SDK version The bridge builds against iOS SDK 7.0.0 and later only (it imports ``, where 7.0.0 moved the wrapper SPI). Since iOS SDK 7.0.0-beta7, and unchanged in 7.0.0, a logged exception takes only `domain` (the wrapper passes `UnityManagedException`, as on Android) and `skipFrames` (which Android ignores since the wrapper's Java stack was dropped, #107), so `Bugsee.LogException(exception, options)` honours only the `skipFrames` key on iOS. `labels`, `includeVideo` and `mergingRules` are dropped (with a one-time warning in the Unity console and the native log): a logged exception takes no labels and always carries the live capture. (Labels are not attached through a report handler either: nothing on the report identifies it as the exception's, and a wrong label is worse than none.) On the simulator the SDK files no logged exception (see the simulator note above). Exceptions are only validated end-to-end on a device. `DeleteCollectedDataOnDevice` and `DeleteScope.Everything` use the SDK's delete-everything form (it also deletes report bundles not uploaded yet and unsent crashes); the narrower scopes call `deleteCollectedDataOnDevice:completion:` with `includingIntermediate` NO or YES, which keeps the bundles and the unsent crashes. ### Developing against an unreleased iOS SDK To build the Unity project against a bugsee-cocoa checkout whose tag does not exist yet, assemble a local package and point the export at it: ```sh Tools~/scripts/assemble-local-ios-sdk.sh [version, 7.0.0 or later] export BUGSEE_IOS_SDK_LOCAL_PACKAGE= # read by the iOS export post-process sh Tests~/iOS/run-tests.sh # bridge tests against the same build ``` The script builds the xcframework as the beta release does (`scripts/build_new.sh`), then lays out the package `bugsee/spm` carries with a path `binaryTarget` (`Sources/BugseeSwiftUI`, and `Sources/BugseeCrashExtension` when the checkout has it, which the 7.0.0 manifest requires; the script fails when the manifest names a path the package lacks, and the export copies all of `Sources`). Nothing is published. With the variable set, the post-process copies that package next to the Xcode project instead of adding the pinned `bugsee/spm` tag and logs a warning; a directory without `Package.swift` and `Bugsee.xcframework` fails the build, and a release export (one built without `BuildOptions.Development`) ignores the variable unless `BUGSEE_IOS_SDK_LOCAL_PACKAGE_ALLOW_RELEASE=1`. Unset, the pinned tag is used. A relative `BUGSEE_IOS_SDK_LOCAL_PACKAGE` is resolved against the Unity process's working directory (the project folder in batchmode). The package is copied (also from a read-only source) before the Xcode project is touched, any failure of the SPM step fails the build, and a refused or failed export leaves the SPM link of the project as it was; later post-processors, such as the symbol-upload Run Script injection, still run. An export refuses (build error) to replace a `Bugsee/` folder at the Xcode project root that it did not copy there itself. Known edges: a re-export removes every earlier link to the official repository spelled as `https://github.com/bugsee/spm.git` and a local package at `Bugsee` that provides a product named `Bugsee`, including one of your own; the same repository under another spelling (no `.git`, other case) is not recognised, so the project then has two references and Xcode may pick yours over the pin. ### Attributes `SetAttribute` accepts a string (up to 1024 UTF-16 units), a bool or a number within the signed 64-bit range; anything else throws `ArgumentException`. `GetAttribute` returns the kind that was set: `string`, `bool`, an integer or a `double`. The numeric width is not promised (both platforms return `long` for an integer and `double` for floating point), and a 1.0 set as floating point stays floating. A map, list or array set from managed code in a report handler (`IReport.SetAttribute`) is stored by the Android SDK as JSON text (valid JSON of at most 8192 characters; entries that do not fit are dropped whole) and reads back as that string, while iOS stores it as a native structure and the handler's report keeps the managed container; a container set natively reads as a `Dictionary` on Android and as JSON text on iOS. On iOS the bridge returns the value as a type tag and payload (`s:`, `b:`, `i:`, `d:`, `j:`; see `AttributeWire`); the SDK stores the plain value, so reports show it unwrapped. ### Trace values `Bugsee.Trace(name, value)` sends a value in these forms on both platforms: - A map (`IDictionary`), list or array (any `ICollection`, including generic collections) is written as JSON of at most 8192 UTF-16 units (invariant culture; a map entry whose value is `null` is left out, a `null` list element is `null`; a collection that contains itself writes `null` where it repeats). A container that does not fit keeps its leading entries whole and drops the rest, so the text is always valid JSON and is never cut inside an entry or an emoji. The iOS SDK receives that JSON as a dictionary or array; the Android SDK receives the same text as a string. Android used to record the type name (``System.Collections.Generic.Dictionary`2[...]``). - A string, bool, int or long is sent as is; a float or double stays floating (`1.0f` is `1.0`, never the integer 1). NaN and the infinities have no JSON form: iOS sends `null`, Android passes the non-finite number itself (the Android SDK drops a trace whose value is null, so mapping it to null there would lose the trace). An enum is its integer value, a `DateTime` or `DateTimeOffset` its ISO 8601 text, a `byte[]` its base64 text, and any other type its culture-invariant text. Other enumerables that are not collections (a Unity `Transform`, for example) are sent as text, not iterated. `Bugsee.GetAllAttributes()` returns a read-only snapshot of every attribute currently set, each typed as `GetAttribute` reads it (a container set natively reads as a nested dictionary or list on Android and as JSON text on iOS); it is never `null` (empty when none is set) and does not change when attributes change later. ### Launch options and notifications `Bugsee.GetLaunchOptions()` returns the options the SDK is running with (its defaults with the ones given to the last `Launch` or `Relaunch` merged over them) as a read-only snapshot, or `null` while the SDK is not launched. Keys are each platform's own option names, so they are not the same on Android and iOS. Values are `string`, `bool`, `long` or `double` on both platforms (the SDK's narrower `int`/`float` defaults are widened), or a nested `Dictionary` / `List`; a value with no such form (a date, a Java array) reads as its text. The SDK's internal keys (a double-dollar-sign name, bare or after the `com.bugsee.option.` prefix, such as the endpoint) are not included, and the Unity-only `unity.*` options are not reported on Android and can be echoed on iOS, so the result cannot rebuild the full set for a `Relaunch`: pass the set you launched with. `Bugsee.GetHostLaunchOptions()` returns only the options the app passed to `Launch` or `Relaunch`, without those defaults, so "the app asked for this" can be told from "this is the SDK default". It is a read-only snapshot with the same keys, value types and left-out internal keys as `GetLaunchOptions()`, and is never `null`: empty before the first launch and when nothing was passed. It keeps describing the last applied configuration after `Stop` and is replaced, not merged, by the next `Launch` or `Relaunch` (a `Relaunch` with no options leaves it empty). Before the first launch it is empty unless the SDK restored the previous run's configuration, which it then returns. On iOS an option passed with its default value may be missing (the SDK drops typed options equal to their default), and the wrapper's own `com.bugsee.option.unity.*` keys appear (Android drops them). `Bugsee.Notify(title, body = null, severity = IssueSeverity.Medium, fields = null, urgent = false)` relays a lightweight notification to the app's messaging integrations without creating a report (no video, logs or events). It is stored offline and sent in batches; `urgent` asks for immediate delivery. A call with an empty title, or before the SDK is launched, is ignored by the native SDK (the title case also logs a Unity warning). `fields` are extra string pairs; entries with a null key or value are dropped. The severity is always sent, so the native default for the shorter overloads is not used. `Bugsee.ShowReportDialog(summary, description, severity, labels)` and `Bugsee.Upload(summary, description, severity, labels)` take an optional `IssueSeverity? severity` (default `null`). Leave it out and the SDK picks its default, the `ReportingDefaultBugPriority` launch option (High when it is not set), on both platforms; an explicit severity is used as given. Code that passed `IssueSeverity.High` explicitly is unchanged. The parameter type changed from `IssueSeverity` to `IssueSeverity?` call sites compile as before (source compatible), but it is a binary-incompatible change: a precompiled assembly built against the old signature must be recompiled, and a delegate bound to these methods or an implementation of `IBugseeNativeBridge` must take `IssueSeverity?`. An explicit `(IssueSeverity)0` is not a severity and counts as omitted. ### Breadcrumbs and the log filter Breadcrumbs are off by default on both native SDKs (`CaptureBreadcrumbs`). While it is off, `Bugsee.AddBreadcrumb` records nothing and the breadcrumb filter is never called; launch with `CaptureBreadcrumbs = true` to use either. (The Android SDK's own Javadoc and `api-7.x.md` say the default is true; that is wrong.) `Bugsee.Log(message, level)` uses the native log API, which skips the log filter by default. `Bugsee.Log(message, level, requiresFiltering: true)` opts in on both platforms (Android `Bugsee.log(message, level, boolean)`, iOS `+log:level:requiresFiltering:`): the line then goes through the filter set with `SetLogEventFilter`, which can edit or drop it (#190). The log filter sees the captured logs: the Unity log the wrapper forwards, and logcat on Android (both need `CaptureLogs`). `Bugsee.Log` lines themselves are recorded, and the opt-in ones filtered, even with `CaptureLogs` off. iOS also drops a `Bugsee.Log` line below `CaptureLogsLevel` before the filter runs (Android applies that level only to the logcat path), so an opt-in Debug line under a preset such as `minimal` (Error level) never reaches the filter on iOS. Android runs the filter during the `Log` call, iOS runs it asynchronously: a log filter must not call `Bugsee.Log(..., true)` itself, which would recurse on Android. ### Filters and the report handler while the Unity loop is paused The network, log and breadcrumb filters and the report handler run on the Unity main thread. On Android the SDK calls them on its own threads and the wrapper hands each one to the main thread, which drains its queue in `Update`; while the app is in the background Unity's loop is paused (and Android may freeze the whole process after about a minute), so they wait until it resumes. On iOS the SDK calls the report handler on the main thread, where Unity runs, so it is not queued; filters are called on SDK threads and queued the same way. In the iOS SDK source the filter decision is a block the SDK stores and calls later, with no wait or semaphore in the filter paths, so no SDK thread is held for Unity (read from the SDK source of the 7.0.0-beta7 era; the 7.0.0 headers say the decision block may be called later, within 10 s, and that is not measured on a device). The Android callbacks are asynchronous in the same way. - **Filters** are not given a wrapper timeout and have no pass-through default. A filter that redacts must run before the event is recorded, and an unfiltered pass-through would leak what it exists to remove. A paused loop therefore only delays the reply: the queued filter runs on resume and its answer is applied, unless the SDK has given up on it first. Android's log filter is dropped by the SDK after 10 s without a reply. The network and breadcrumb filters have no SDK timeout in the 7.4.1 and 7.4.2 releases (the published 7.4.1 and 7.4.2 AARs contain the 10 s message for the log filter only; the SDK's source tags for those versions do have a 10 s network-filter timeout, which the published AARs do not contain, so the wrapper follows the AARs and gives the network filter no reply window; if a released AAR gains it the window must be extended), and an unanswered breadcrumb filter leaks one pooled entry in the SDK. iOS SDK 7.0.0 drops a network, log or breadcrumb event whose decision block is not called within 10 s (a later call is ignored), as the Android log filter does (from the 7.0.0 headers, not measured on a device); 7.0.0-beta7 had no timeout. A filter that throws drops the event, as before. A filter that blocks forever blocks the main thread, which no wrapper timeout can help. - **Upstream (Android SDK), not fixed here:** the SDK reuses the log filter's callback object for the next event after its 10 s timeout and does not check which event a reply belongs to. A reply that arrives after the timeout, say from a queue that sat behind a paused loop, can therefore complete the next event with the old event's data. The wrapper withholds a log-filter reply that would come after the 10 s window (counted from the SDK's call), so it does not trigger this, but another caller of the SDK could. A filter the wrapper withholds the reply of, or skips, is logged as a warning. The network filter has no timeout in 7.4.1/7.4.2, so it has no reuse and no window. - **The report handler** is bounded by the SDK: it carries on with the report unchanged after `ReportHandlerCallbackTimeout` (30 s by default; `0` disables only the per-handler timer and the SDK still ends the chain at 60 s). iOS SDK 7.0.0 uses the same 30 s per callback (a callback the main thread cannot start in that time is skipped) but does not read the option. The wrapper follows the same clock, started when the SDK calls it: a before-phase handler that only gets to run after the SDK has moved on is skipped (Android, where a paused loop can hold it; a warning is logged), while a late after-phase handler, usually a notification, still runs with a completion that only acknowledges, a reply that arrives after it is acknowledged without applying the handler's edits (iOS), and the completion callback is honoured once. A handler that never calls `completionCallback` is abandoned a second after that deadline, which completes the report unchanged and releases the native completion (Android), or the native entry, the report and its snapshot files (iOS); a reply after that does nothing. An iOS handler still holding the report then finds its attached snapshot files gone. - Android: the report and its attachments handed to a handler stop accepting edits (they do nothing) once the handler's completion has run, whether it answered, was skipped or was abandoned, so a handler that kept the report cannot change it after the SDK moved on. Reads still work. A handler that is still running when the SDK moves on can make edits until its completion runs or the abandon fires a second after the deadline. The timeout is read from the launch options at most once a minute, and again after a Launch or Relaunch (the last value is kept if they cannot be read). - Small window: the SDK's timer starts slightly before the wrapper's clock (on iOS, a hop to the main thread), so a reply that arrives in that gap can still write its edits after the SDK moved on. ### Performance transactions and spans (APM) ```csharp using (var checkout = Bugsee.StartTransaction("checkout", "user.flow", new Dictionary { ["cart"] = 3 })) using (var pay = checkout.StartChild("payment", "charge card")) { pay.SetAttribute("provider", "stripe"); // ... work ... pay.Finish(); // Dispose without Finish also finishes with Ok checkout.SetStatus(SpanStatus.Ok); } ``` `Bugsee.StartTransaction(name, operation, attributes = null)` returns an `ISpan` (`SpanId`, `TraceId`, `Operation`, `IsFinished`, `SetName`, `SetDescription`, `SetAttribute`, `SetStatus`, `StartChild(operation, description = null)`, `Finish()` / `Finish(SpanStatus)`, `Dispose` = `Finish()`). Attribute values follow the `SetAttribute` rules; a rejected value is dropped with a Unity warning (spans never throw). The statuses are `Ok`, `Error`, `Timeout`, `Cancelled`, `DeadlineExceeded` and `Unknown`. A span wraps a native span, so finish or dispose every span you start. Finishing (or disposing) a span releases the native object; finishing a parent first finishes its still-live children as `Cancelled`. A span that is dropped without finishing is not reported as finished, and on iOS its native handle is released by a finalizer. After `Finish` every call on the span does nothing. `StartTransaction` returns an inert span that accepts every call (empty ids, reads as finished after `Finish`) while the SDK is not launched or when the name or operation is empty. With performance monitoring off the native SDK returns its shared no-op span (ids read `"0"`), which is wrapped like any other span. While the SDK is not launched (including while it is still launching) the wrapper itself returns an inert span with empty ids. No call on a span throws: invalid input and native failures log a Unity warning. If a child finishes on another thread while its parent finishes, the status that reached the child first wins. Spans are only created from a parent: `startSpan` and `getActiveSpan` are not exposed, because the native SDKs track the active span per thread (on iOS it is not propagated across `dispatch_async`). A span can be used from any thread, including thread-pool and `Task` threads: on Android a managed thread-pool thread is attached for the duration of each call (one attach for a whole `Finish`) and detached again, because the JVM aborts the process on a JNI call from an unattached thread; the main thread, Java-owned threads and threads you attached yourself are never attached or detached by the wrapper, so do not use spans from a pool thread you attached yourself, and on iOS the handle is an id. A parent finished on one thread while a child finishes on another is safe. Full product documentation: [docs.bugsee.com/sdk/unity](https://docs.bugsee.com/sdk/unity/). ## Experimental: Unity frame pusher (Android) Not benchmarked beyond one tablet; do not enable it in production without measuring. Nothing here changes unless you opt in: by default the Android SDK captures the window itself (`VideoMode.V2`), and the capturer only runs for a launch that asks for `VideoMode.DirectBuffers` (or an explicit `Enable()` call). **Unity versions.** Supported: release builds (channel `f` or `p`) of Unity 2022.2.0f1 and newer, Android player builds, with the Screen Capture module. `AndroidJNI.NewDirectByteBuffer` first appears in 2022.2.0a11 (checked against Unity's reference source: 2022.2.0a1, 2022.1 and 2021.3 do not have it; 2022.2.0b1, all of 2022.3 LTS and 6000.x do), but alpha and beta builds are treated as unsupported. **Not supported: Unity 2021.3 and 2022.1.** The only alternatives there (a Java `byte[]` per frame, or a file) were measured and rejected (about 0.9 s per 1 MB frame, or disk writes). The minimum is one constant, `UnityCapturePolicy.MinimumUnityVersion`, plus the `BUGSEE_UNITY_CAPTURE` version define (`2022.2.0`) in `Bugsee.Runtime.asmdef`. **Falling back to the default capture.** `VideoMode.DirectBuffers` means "the app pushes the frames", and in Unity the only frame source is this capturer. So you ask for it with the launch option alone (no `Enable()` call needed): `Bugsee.Launch` / `Relaunch` start the capturer, with `BugseeFrameCapturer.DefaultOptions` (set it before launching). If it cannot run, the wrapper itself, before the options reach the native SDK, replaces `DirectBuffers` with the default capture (`VideoMode.V2`) and logs one warning with the reason, so the session never runs in `DirectBuffers` without a frame source (that records no real video). Reasons: the player was not probed yet (a launch from another thread before Unity finished starting), Unity that is not a release build of 2022.2.0f1 or newer, no Screen Capture module, no `AsyncGPUReadback` on the device, a graphics API whose readback row order was not measured (OpenGLES3 and Vulkan are measured; set `DefaultOptions.RowOrder` to declare another), or the capturer failing to start after the launch was accepted (then the wrapper relaunches with the default capture, unless a newer Launch/Relaunch is waiting, which then decides). The capturer follows what the native SDK actually did: an ignored Launch (SDK already running) or a refused one leaves it alone, and an accepted one is read back from the SDK's effective launch options. Other video modes are never touched. Apps that push frames themselves through the native `getVideoFrameConsumer()` are affected too: use a native mode there or this fallback applies. ```csharp // using Bugsee.Capture; #if UNITY_ANDROID && !UNITY_EDITOR BugseeFrameCapturer.DefaultOptions = new BugseeFrameCapturerOptions { TargetFps = 5, MaxDimension = 640 }; // optional Bugsee.Launch(token, new AndroidLaunchOptions { CaptureVideo = true, CaptureVideoMode = VideoMode.DirectBuffers }); #endif ``` How it works: at the end of each due frame it calls `ScreenCapture.CaptureScreenshotIntoRenderTexture`, scales into a small RenderTexture and reads it back with `AsyncGPUReadback` (never a synchronous read). One request is in flight at a time; frames that come due meanwhile are dropped, not queued. The readback is copied once into a persistent native buffer, secure rectangles are blanked in place, and a push thread wraps that memory as a Java direct `ByteBuffer` for `VideoFrameConsumer.addFrame` with the SDK's own clock as the timestamp. No Java array, and the wrapper writes no frame to disk (the SDK itself still writes its recorded video as usual). `BugseeFrameCapturer.Stats` shows requested, pushed, failed and dropped counts; `BugseeFrameCapturerOptions.LogStats` also logs them every 10 s. `Enable()` called off the main thread is queued and returns true before it ran; check `IsEnabled`. What to know before using it: - Needs `VideoMode.DirectBuffers`. With any other mode the SDK ignores the frames; with `DirectBuffers` and no `Enable()` nothing pushes frames, so there is no real video. - It records Unity's final composite, including screen-space overlay UI. Native Android views (WebViews, dialogs, system UI) are not in the video. - Redaction: the SDK does not mask frames pushed this way: no secure rectangles, no secure views, and no pixelation. The pusher blanks rectangles registered with `Bugsee.AddSecureRectangle`, read as native screen pixels (top-left origin; the same as window pixels when Unity's window fills the screen). They are mapped relative to where Unity's view sits in the window (its position and size, read again when each capture starts and when its pixels arrive, so a status bar, cutout or multi-window offset is accounted for) and scaled to the frame; if that position cannot be read, or the surface found does not have the aspect ratio of Unity's screen (a plugin's SurfaceView, or a view caught mid-rotation), the whole frame is blanked while a rectangle is registered. A rectangle is masked if it was registered when the capture started or when the pixels arrived. Secure native views are not known to it. Blackout is honoured by the SDK. - Row order of the readback was measured for Vulkan (Galaxy Tab S5e, Android 11, Adreno 615, Unity 6000.0.84f1: TopDown) and for OpenGLES3 (Android 16 arm64 emulator, swiftshader, Unity 6000.0.84f1: BottomUp, with a red-over-blue pattern; no GLES3 device was measured). For any other graphics API (OpenGLES2) it is unverified: the launch falls back to the default capture (above), and a capturer started directly with `Enable()` fails closed (every frame fully black while a secure rectangle is registered). Check the order on your device with `BugseeFrameCapturerOptions.LogOrientationProbe` (the sample's `bugsee_frame_pattern=1` shows a red-over-blue pattern; red in the first logged row means TopDown) and then set `BugseeFrameCapturerOptions.RowOrder`, which declares it verified. - Readback is refused when the device lacks `SystemInfo.supportsAsyncGPUReadback`, or on Vulkan with Unity older than 2021.3.18 (not reachable on supported versions). After 5 failed readbacks in a row it turns itself off. - The SDK caps pushed frames by `CaptureVideoFrameRate` as well; a `TargetFps` above that is dropped by the SDK. - Measured once, on a Galaxy Tab S5e (Android 11, Unity 6000.0.84f1 IL2CPP development build, Vulkan, the sample scene, 400x640 capture at `TargetFps` 5, about 100 s per run, pusher on versus the SDK's default capture): about 4.6 frames/s pushed, 0 failures, 1-3 frames dropped in flight; readback latency about 81-91 ms; `addFrame` 18-19 ms on the push thread. Unity frame rate 37.5-38.1 versus 37.6-37.9 fps, frame time p50 33.1 ms and p95 33.2 ms in both. CPU is comparable, not lower: the push thread used about 10% of a core, against about 9% for the default capture's `BugseeScreenCap` thread; main thread about 50-57% either way; total PSS 391-396 MB versus 374-382 MB (about 15 MB more for the render textures and buffers). So it is not lighter than the default capture on this device. One device and one light scene, not a benchmark of heavier games. - Decoded report videos (640x640 h264 from staging reports UNITYTA-35 to 43; red-top/blue-bottom pattern, a top-left and a bottom-right secure rectangle): red above blue (no mirroring) on both Vulkan and OpenGLES3 (the tablet also ran OpenGLES3 in one build: BottomUp, same result); frames before a rectangle was registered are unmasked, then every frame while it was registered has both rectangles black at the right place, then after removal the same areas show the pattern again, with no unmasked frame inside the masked period and no masked frame after removal. A rectangle added after a rotation (landscape to portrait, driven by `Screen.orientation` from the sample) is masked at the right place, and the view region followed the rotation (2560x1600 to 1600x2560). With the status bar shown the Unity view was 2560x1492; a rectangle at window pixels (0,0)-(800,400) was masked to exactly the area it covers in that view (frame x 0-199, y to 233), i.e. relative to the view, not the window. A launch from Unity 2021.3.45 with DirectBuffers requested logged the fallback warning and recorded a normal default-capture video (UNITYTA-43). A `Bugsee.Launch` from a worker thread with DirectBuffers works (after a fix: `AndroidBridge.Launch` read Application.buildGUID off the main thread). Limits: the wrapper learns a launch's outcome only until the lifecycle deadline (10 s); if the native SDK answers a request later than that, the answer is not delivered, the pusher follows the earlier refusal, and a native session that then runs in DirectBuffers without a pusher is not detected. Not verified on a device: a view whose top offset is non-zero (the status bar here sat at the bottom), split-screen or a display cutout, the fail-closed blanking when the view position cannot be read (unit tests only), OpenGLES2, Unity 2022.3 and Unity 2022.2 (not built), and heavier scenes.