capacitor-assets icon indicating copy to clipboard operation
capacitor-assets copied to clipboard

Bug - Android rounded icon generation hangs indefinitely

Open dobripet opened this issue 1 year ago • 1 comments

Hi, we are facing following issue in our CI server. When building android assets it gets stuck when composing round icons and awaits for half of them never finish. To get it working I had to set environment variable UV_THREADPOOL_SIZE to 1. This might be just issue for sharp itself or maybe newer version of sharp works, no idea.

I added some debugging logs to the android platform index file as following.

image

And this is the output:

09:16:11   Android basic icons collected. 09:16:11   Android rounded icon started: ldpi 09:16:11   Sharp queue contains 1 task(s) 09:16:11   Android rounded icon started: mdpi 09:16:11   Sharp queue contains 2 task(s) 09:16:11   Android rounded icon started: hdpi 09:16:11   Sharp queue contains 3 task(s) 09:16:11   Android rounded icon started: xhdpi 09:16:11   Sharp queue contains 4 task(s) 09:16:11   Android rounded icon started: xxhdpi 09:16:11   Sharp queue contains 5 task(s) 09:16:11   Android rounded icon started: xxxhdpi 09:16:11   Sharp queue contains 6 task(s) 09:16:11   Sharp queue contains 6 task(s) 09:16:11   Sharp queue contains 2 task(s) 09:16:11   Sharp queue contains 1 task(s) 09:16:11   Android rounded icon resized: \android\app\src\main\res\mipmap-ldpi\ic_launcher_round.png sharp concurrency: 4 sharp counters: { queue: 1, process: 4 } 09:16:11   Sharp queue contains 1 task(s) 09:16:11   Sharp queue contains 0 task(s) 09:16:11   Android rounded icon resized: \android\app\src\main\res\mipmap-mdpi\ic_launcher_round.png sharp concurrency: 4 sharp counters: { queue: 0, process: 5 } 09:16:11   Sharp queue contains 1 task(s) 09:16:11   Sharp queue contains 1 task(s) 09:16:11   Android rounded icon resized: \android\app\src\main\res\mipmap-hdpi\ic_launcher_round.png sharp concurrency: 4 sharp counters: { queue: 1, process: 4 } 09:16:11   Sharp queue contains 2 task(s) 09:16:11   Sharp queue contains 1 task(s) 09:16:11   Android rounded icon resized: \android\app\src\main\res\mipmap-xhdpi\ic_launcher_round.png sharp concurrency: 4 sharp counters: { queue: 1, process: 4 } 09:16:11   Sharp queue contains 2 task(s) 09:16:11   Sharp queue contains 1 task(s) 09:16:11   Android rounded icon resized: \android\app\src\main\res\mipmap-xxxhdpi\ic_launcher_round.png sharp concurrency: 4 sharp counters: { queue: 1, process: 4 } 09:16:11   Sharp queue contains 2 task(s) 09:16:11   Sharp queue contains 2 task(s) 09:16:11   Android rounded icon resized: \android\app\src\main\res\mipmap-xxhdpi\ic_launcher_round.png sharp concurrency: 4 sharp counters: { queue: 1, process: 4 } 09:16:11   Sharp queue contains 2 task(s) 09:16:11   Sharp queue contains 0 task(s) 09:16:11   Android rounded icon composited: \android\app\src\main\res\mipmap-mdpi\ic_launcher_round.png sharp concurrency: 4 sharp counters: { queue: 0, process: 5 } 09:16:11   Sharp queue contains 1 task(s) 09:16:11   Sharp queue contains 0 task(s) 09:16:11   Android rounded icon composited: \android\app\src\main\res\mipmap-xxxhdpi\ic_launcher_round.png sharp concurrency: 4 sharp counters: { queue: 0, process: 5 } 09:16:11   Sharp queue contains 1 task(s) 09:16:11   Sharp queue contains 1 task(s) 09:16:11   Android rounded icon composited: \android\app\src\main\res\mipmap-xxhdpi\ic_launcher_round.png sharp concurrency: 4 sharp counters: { queue: 1, process: 4 } 09:16:11   Sharp queue contains 2 task(s) 09:16:11   Sharp queue contains 0 task(s) 09:16:11   Android rounded icon outputted: \android\app\src\main\res\mipmap-mdpi\ic_launcher_round.png sharp concurrency: 4 sharp counters: { queue: 0, process: 5 } 09:16:11   Android rounded icon finished: mdpi 09:16:11   Sharp queue contains 0 task(s) 09:16:11   Android rounded icon outputted: \android\app\src\main\res\mipmap-xxxhdpi\ic_launcher_round.png sharp concurrency: 4 sharp counters: { queue: 0, process: 4 } 09:16:11   Android rounded icon finished: xxxhdpi 09:16:11   Sharp queue contains 0 task(s) 09:16:11   Android rounded icon outputted: \android\app\src\main\res\mipmap-xxhdpi\ic_launcher_round.png sharp concurrency: 4 sharp counters: { queue: 0, process: 3 } 09:16:11   Android rounded icon finished: xxhdpi

And after last logged line process will hang forever till killed.

Also instead of awaiting Promise.All for rounded icons I tried to generate them sequentially in for loop and awaiting individual icons and it worked as well so there is probably something wrong with parallel composition / threading.

Sometimes (rarely) it got stucked even on my local environment which is more powerful and where I got sharp concurrency 12.

Thank you for any feedback.

dobripet avatar May 17 '23 07:05 dobripet

Facing the same issue in local from my end as well. I am yet to integrate with the CI server. Thank you for the above workaround. Will try it out.

bharath-sampath avatar May 18 '23 05:05 bharath-sampath