Skip to content

Commit

Permalink
reduced bitmap size and background worker count in ProfilingSampleAct…
Browse files Browse the repository at this point in the history
…ivity to reduce the likeliness of ANRs during tests (#3138)
  • Loading branch information
stefanosiano authored Jan 12, 2024
1 parent 174dacb commit c554ca2
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ class ProfilingSampleActivity : AppCompatActivity() {
}

private lateinit var binding: ActivityProfilingSampleBinding
private val backgroundThreadPoolSize = 2
private val executor: ExecutorService = Executors.newFixedThreadPool(backgroundThreadPoolSize)
private val executor: ExecutorService = Executors.newFixedThreadPool(1)
private var resumed = false

override fun onCreate(savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -64,10 +63,8 @@ class ProfilingSampleActivity : AppCompatActivity() {
resumed = true

// Do operations until the activity is paused.
repeat(backgroundThreadPoolSize) {
executor.execute {
fibonacci(50)
}
executor.execute {
fibonacci(50)
}
}

Expand Down Expand Up @@ -99,7 +96,7 @@ internal class ProfilingSampleListAdapter : RecyclerView.Adapter<ViewHolder>() {

@Suppress("MagicNumber")
private fun generateBitmap(): Bitmap {
val bitmapSize = 512
val bitmapSize = 256
val colors = (0 until (bitmapSize * bitmapSize)).map {
Color.rgb(Random.nextInt(256), Random.nextInt(256), Random.nextInt(256))
}.toIntArray()
Expand Down

0 comments on commit c554ca2

Please sign in to comment.