-
Notifications
You must be signed in to change notification settings - Fork 35
WebGL: Add offline support #265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
- Flush IDBFS to IndexedDB on browser lifecycle events. - Add PlayerPrefs offline queue fallback when BacktraceDatabase is unavailable.
konraddysput
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BacktraceClient represents a business logic not related to the database. We have a dedicated class implementation for it, which is BacktraceDatabase. Mixing business logic and database implementation in the client is the wrong decision long term. Instead, you need to use BacktraceDatabase and use abstraction to properly implement a proper database logic for webgl /webgl database operations.
Please also look at the project structure to follow the file pattern.
|
|
||
| // WebGL builds may have multiple BacktraceClient instances if DestroyOnLoad is enabled. | ||
| // Ensure only one instance performs offline queue replay to avoid duplicate sends. | ||
| private static BacktraceClient _webglOfflineReplayOwner; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we already have a static Backtrace instance available here.
| #if UNITY_WEBGL | ||
| private WebGLOfflineDatabase _webglOfflineDatabase; | ||
| private Coroutine _webglOfflineReplayCoroutine; | ||
| private bool _webglOfflineReplayInProgress; | ||
|
|
||
| // WebGL builds may have multiple BacktraceClient instances if DestroyOnLoad is enabled. | ||
| // Ensure only one instance performs offline queue replay to avoid duplicate sends. | ||
| private static BacktraceClient _webglOfflineReplayOwner; | ||
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be moved to BacktraceDatabase - BacktraceDatabase offerts the same Untiy scope.
| } | ||
| } | ||
| #if UNITY_WEBGL | ||
| private void InitializeWebGLOfflineSupport() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be abstracted in the BacktraceDatabase implementation - we have the Start/Awake support there.
webgl db logic can be easily moved out of The fine-line/strategy -here- was to diverge temporarily and quickly unblock webgl integrators while we work on providing real targeted support for webgl as a first-class platform (rather than relying on default/general/other platforms implementations). If this PR adds too much noise, we can close it and work on webgl offline support after/under the broader webgl scope. |
Context
WebGL users can lose unsent Backtrace reports when:
and/or
Solution
Persist offline reports reliably (IDBFS flush hooks + PlayerPrefs fallback queue)
This PR adds two WebGL-specific reliability layers consistent with existing Backtrace database settings:
BacktraceSync.jslibexposingFS.syncfsBacktraceWebGLSync.cswrapperpagehide,beforeunload,visibilitychange,freeze) and callsFS.syncfsat key SDK lifecycle points to reduce data loss.WebGLOfflineDatabase.csPlayerPrefs queue.BacktraceConfigurationdatabase settings (MaxRecordCount,MaxDatabaseSize,RetryLimit,RetryOrder,RetryInterval,AutoSendMode)AutoSendModeis enabled.Notes / Limitations
FS.syncfsis best-effort and async: abrupt tab termination can still lose data.PlayerPrefsqueue is intentionally bounded: oversized reports are not persisted.Sample Reports
ref: BT-6231