Skip to content

Performance improvements and enhanced error handling#14

Open
RamiAhmed wants to merge 10 commits into
aptabase:mainfrom
RamiAhmed:main
Open

Performance improvements and enhanced error handling#14
RamiAhmed wants to merge 10 commits into
aptabase:mainfrom
RamiAhmed:main

Conversation

@RamiAhmed

Copy link
Copy Markdown

Summary

Performance optimizations and improved error handling for production Unity applications.

Changes

  • Memory optimization: Use ListPool and DictionaryPool to reduce GC allocations
  • Async improvements: Flush() now returns Task with CancellationToken support throughout the call chain
  • Better error handling: Comprehensive HTTP status code handling with actionable error messages

Technical Details

// Before: new allocations every time
var props = new Dictionary<string, object>();

// After: pooled allocations
var props = DictionaryPool<string, object>.Get();
// ... use ...
DictionaryPool<string, object>.Release(props);

// Cancellation support
await Aptabase.Flush(cancellationToken);

Testing

✅ Verified memory reduction via Unity Profiler
✅ Tested cancellation token propagation
✅ 100% backward compatible - no breaking changes

Benefits

  • Reduced GC spikes in high-frequency event tracking
  • Better async/await patterns for Unity lifecycle
  • Clear, actionable error messages for debugging
  • Improved production readiness

RamiAhmed and others added 4 commits June 17, 2025 13:50
use ListPool and DictionaryPool to avoid unnecessary memory allocations + automatic code cleanup + cancellation handled all the way through to WebRequestHelper
@RamiAhmed RamiAhmed closed this Jun 24, 2026
@RamiAhmed RamiAhmed reopened this Jun 24, 2026
@RamiAhmed

Copy link
Copy Markdown
Author

Hey @NikTheNak @revmarcuspeter-cyber (other devs?)

I'm not able to merge this PR yet (I don't have a 'merge' button?). Are more reviewers required, or?

@RamiAhmed

Copy link
Copy Markdown
Author

I've snuck in another minor addition - support for setting a "response listener" - we wanted to be able to disable our analytics service if we get a 'too many requests' response to avoid spamming the Aptabase servers and save on our own logging and other overhead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants