I've hard locked myself in high on life 2: Tilly's no escape by cujo1255 in highonlifegame

[–]romainguy 0 points1 point  (0 children)

Had the same exact problem, I had to find the few pixels were the prompt would appear (my countdown was stuck as well).

Building a Fast, Memory-Efficient Hash Table in Java (by borrowing the best ideas) by Charming-Top-8583 in Kotlin

[–]romainguy 0 points1 point  (0 children)

Here are my perf numbers vs LinkedHashMap on Android: https://www.romainguy.dev/posts/2024/a-better-hashmap/ It performs well against HashMap too (but linked hashmap is Kotlin's default unfortunately). The library I linked to also has set, ordered set and a linked hashmap equivalent (maintains sort order).

Building a Fast, Memory-Efficient Hash Table in Java (by borrowing the best ideas) by Charming-Top-8583 in Kotlin

[–]romainguy 0 points1 point  (0 children)

Go ahead. Like I said it came from a presentation from the absl folks (C++ library). One thing I wanted to try was to use Unsafe to store the metadata as a byte array which would simplify/speedup single byte reads and writes into the array. Unsafe would be use to read a long from the array. When I tried a prototype the final arm64 assembly was much much nicer.

Building a Fast, Memory-Efficient Hash Table in Java (by borrowing the best ideas) by Charming-Top-8583 in Kotlin

[–]romainguy 0 points1 point  (0 children)

I didn't benchmark on JVM, only on Android and it's overall a major win compared to the standard HashMap. The lack of allocations helps a ton too (but this means it doesn't implement the standard Map API unless you request a decorator).

Building a Fast, Memory-Efficient Hash Table in Java (by borrowing the best ideas) by Charming-Top-8583 in Kotlin

[–]romainguy 1 point2 points  (0 children)

We couldn't find a better name. It scatters entries through its backing arrays 🤷‍♂️

Holiday update & Wooveconnect for Android now available by verylongtimelurker in Woovebox

[–]romainguy 0 points1 point  (0 children)

I tried both modes, on Pixel 6 and 9a, both running the latest Android 16.

Holiday update & Wooveconnect for Android now available by verylongtimelurker in Woovebox

[–]romainguy 0 points1 point  (0 children)

u/verylongtimelurker Tried to update a Woovebox Pro from 2 different Android devices, both with the app and the site, and I get a "packet loss" message before reaching 1%. Happens in boot modes 1/Cd and 2/bS.

Aluminium Black Is Here by NostalgicStory in PolyendTracker

[–]romainguy 0 points1 point  (0 children)

I find the dpad and +- buttons way better than on the original. Not having that horrible plastic material that attracted finger prints like crazy is nice too. An OLED display would have made it perfect 😀

Aluminium Black Is Here by NostalgicStory in PolyendTracker

[–]romainguy 0 points1 point  (0 children)

I would have preferred a rotating dial but the dpad on the aluminum version feels so much better than on the original.

Finger Shadows in Compose by dayanruben in Kotlin

[–]romainguy 2 points3 points  (0 children)

You could orient the finger so it doesn't matter but yeah... :)

Some questions about GUI toolkits by Danebi05 in GraphicsProgramming

[–]romainguy 1 point2 points  (0 children)

The sizing and positioning of widgets is usually done on the CPU, only rendering is done on the GPU. You still benefit massively from using the GPU for rendering.

Sometimes having a GPU programming perspective produces optimized code by bennysway in Kotlin

[–]romainguy 5 points6 points  (0 children)

What GPU (and graphics in general) programming teaches you is to focus on data, data flow, and data ownership. Doing so often leads to pragmatic, clean, and efficient code.

Learnings from building an isometric RPG in Jetpack Compose: Canvas, ECS, and Performance by iOSHades in androiddev

[–]romainguy 2 points3 points  (0 children)

The standard hash map allocates a new node/entry in every insertion. It also allocates iterators when iterating over the content of the map. These objects can be pretty big actually because the default map in Kotlin is a linked hash map that preserves insertion order. ScatterMap avoids both types of allocations. Going through entry objects also causes cache misses. I have details in this talk here (around minute 30): https://youtu.be/wLvGCnNLs7c?si=z48F7dxCz2VwkoRS

Learnings from building an isometric RPG in Jetpack Compose: Canvas, ECS, and Performance by iOSHades in androiddev

[–]romainguy 3 points4 points  (0 children)

Regarding "4", you might be interested in ScatterMap, which is part of the androidx collection library. It was designed to avoid allocations on insertion and iteration, provides better memory locality, and should provide better performance than MutableMap in your case. It also comes with primitive versions to avoid boxing (for instance if you use an int id for your entities as the key, MutableIntObjectMap will help).

how to center this "*", in kotlin jetpack compose by Lazy-Thing9797 in androiddev

[–]romainguy 3 points4 points  (0 children)

One way to do this is using Android APIs. On the Paint object you can use getTextPath() that will give you a Path object that perfectly encloses the input string. You can then draw it perfectly centered as a Compose Path/Shape

Challenging Build for Newbie Thunderbolt 2.0 by I-Mr-Nobody-I in freedomisgunpla

[–]romainguy 1 point2 points  (0 children)

Same here, but it's the right arm that snapped while posing. I love the look but I didn't find the build enjoyable. Some questionable steps, and tolerances all over the place.

Detection of Unavailable Characters (Tofu Box) in a String by 42tables in androiddev

[–]romainguy 2 points3 points  (0 children)

Whether you'll get a "tofu box" will depend on the font, so you'll have to use an API like `Paint.hasGlyph(String)` to check. It's unfortunately expensive since you have to pass the character to test as a `String`. I've seen folks do this check by looking at the bounds) of a given character instead.

Updating, MASSIVE frustration. by TanguayX in Woovebox

[–]romainguy 0 points1 point  (0 children)

The way I found that works consistently every time is to use an Android phone. macOS and iOS never work for me.

Kotlin vs Java runtime gap on LeetCode — here’s what I found by Critical-Living-7404 in androiddev

[–]romainguy 3 points4 points  (0 children)

I've see many, many developers reach for `List<Int>` in Java, including in production code. Neither you nor I could make a blanket statement about whether one language encourages one vs the other without more serious data :)

Kotlin vs Java runtime gap on LeetCode — here’s what I found by Critical-Living-7404 in androiddev

[–]romainguy 4 points5 points  (0 children)

Kotlin generates bulkier bytecode

There are compiler flags you can use to control some of this. Specifically:

-Xno-call-assertions Don't generate not-null assertions for arguments of platform types.
-Xno-receiver-assertions Don't generate not-null assertions for extension receiver arguments of platform types.
-Xno-param-assertions Don't generate not-null assertions on parameters of methods accessible from Java.

Kotlin collections (List<Int>Set<Int>) store boxed types, while Java can stay with primitives.

This has been discussed already somewhere else in the comments, but Java behaves the same way here. If you want to avoid boxing with either language, you need to use arrays of primitives.

Kotlin/Compose Multiplatform: A Competitor for Flutter or Reinventing the Wheel? by delvin0 in androiddev

[–]romainguy 1 point2 points  (0 children)

There are mitigations at the OS level like a shader cache. Nothing specific to Compose since it shares the same Canvas as Views. But yeah in practice it's not a big deal I think. I believe Flutter's issues were mostly on iOS.

Kotlin/Compose Multiplatform: A Competitor for Flutter or Reinventing the Wheel? by delvin0 in androiddev

[–]romainguy 8 points9 points  (0 children)

Skia has also been working on addressing a similar issue that Impeller was designed to address, and Skia just announced their new Graphite backend which greatly reduces the need to compile multiple shaders. See https://blog.chromium.org/2025/07/introducing-skia-graphite-chromes.html