Signal-iOS icon indicating copy to clipboard operation
Signal-iOS copied to clipboard

Improve audio messages performance

Open alex1704 opened this issue 10 months ago • 0 comments

Contributor checklist

  • [x] My commits are rebased on the latest main branch
  • [x] My commits are in nice logical chunks
  • [x] My contribution is fully baked and is ready to be merged as is
  • [x] I have tested my contribution on these devices:
  • iPhone 12, iOS 17.4.1
  • iPhone 7, iOS 15.8.2

Description

  • 1st commit: Whenever audio attachment is playing there are a lot of unnecessary work done in AudioWaveformProgressView.redrawSamples. On every audio progress update there are paths recreated for playedShapeLayer and unplayedShapeLayer. In my solution I draw unplayedShapeLayer and playedShapeLayer once and further apply layer mask to playedShapeLayer to show progress.
  • 2nd commit: AudioPlayer triggers update UI progress 20 times per second with Timer. I replaced timer with CADisplayLink which allowed to reduce updates number per second and improve animation smoothness.

Changes in 2 commits reduced CPU usage from 13% to 5% on my iPhone 12 (17.4.1).

alex1704 avatar Apr 15 '24 12:04 alex1704