Everyday Unity – Telegram
Everyday Unity
1.11K subscribers
157 photos
59 videos
42 files
2.36K links
A game developer and tech lead in a top grossing company posting Unity, programming, and gamedev related stuff that I find interesting
Website: https://gamedev.center

Most used tags are:
#performance
#shader
#interview

Author: @alexmtr
Download Telegram
https://markheath.net/post/async-antipatterns

Async await antipatterns:
1. Forgotten await
2. Ignoring tasks - The danger with this approach is that nothing is going to catch any exceptions thrown. At best, that means you didn't know it failed to complete. At worst, it can terminate your process. So use this approach with caution, and make sure the method has good exception handling.
3. Using async void methods - The trouble is, that the caller of the method has no way to await the outcome of this method. They have no access to the Task that awaited method returned. So you're essentially ignoring a task again.
4. Blocking on tasks with .Result or .Wait - there are some problems here. The first is that using blocking calls like Result ties up a thread that could be doing other useful work. More seriously, mixing async code with calls to .Result (or .Wait()) opens the door to some really nasty deadlock problems.
5. Mixing ForEach with async methods
6. Excessive parallelization
7. Non-thread-safe side-effects - prefer pure functions instead of relying on the calling method to run on the main thread.
8. Missing ConfigureAwait(false) - not so useful for Unity since its api is not thread safe
9. Ignoring the async version
10. try catch without await - dont return Task inside try-catch since the catch will not be triggered if exception happens inside task. It can only be triggered on task creation.

#async #patterns
Understanding Audio Compression Settings in Unity

https://medium.com/double-shot-audio/understanding-audio-compression-settings-in-unity-e879a821023f

Vorbis requires significantly higher CPU resources to decompress the audio for playback.

One major difference between MP3 and Vorbis is that MP3 cannot loop seamlessly.

PCM is lossless compression and, while light on the CPU, has a much larger file size

ADPCM has a fixed compression ratio of about 3.5 and, while a good compromise between PCM and Vorbis/MP3, can sometimes cause unwanted noise (quantitative distortion) in audio files with lots of high-frequency content

Vorbis is a very efficient audio codec that offers high-quality lossy compression but requires more CPU resources for decompression

MP3 also offers high-quality lossy compression but causes problems for audio assets that should loop

#audio #settings #compression