kirillzyusko / react-native-keyboard-controller

Keyboard manager which works in identical way on both iOS and Android
https://kirillzyusko.github.io/react-native-keyboard-controller/
MIT License
1.58k stars 64 forks source link

Logging & performance #576

Closed RohovDmytro closed 1 week ago

RohovDmytro commented 1 week ago

By inspection logs I've observed a bit of logging in Android:

https://raw.githubusercontent.com/kirillzyusko/react-native-keyboard-controller/e852dd9af5fd1d30edaf0e684b6de8517a767697/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt

Does it hurt the performance in production? Should we have an option to disable it during production during animation?

kirillzyusko commented 1 week ago

Thanks for bringing this @RohovDmytro

Yeah, I've been thinking on disabling these logs by default (I added them, but I didn't receive issues where such logging would be helpful).

It shouldn't have a big impact on performance (in my case it was nanoseconds per frame, so it doesn't really matter), but spamming logcat with those logs also not a good approach.

I think the ideal solution here would be to add a custom Logger-class that disabled by default, but if you need to capture logs (for debugging purposes) then you can enable it.

What is the industry standart for such things? 👀

RohovDmytro commented 1 week ago

Aaaawesome! I will use this as an opportunity to send a huge respect for this library. It's awesome and it saved me from a nasty, nasty keyboard-management situation. Appreciate!

🤝

RohovDmytro commented 1 week ago

Speaking about perf impact I did not made any measurements, my thinking was that during animations specifically logging might have some impact.

kirillzyusko commented 1 week ago

my thinking was that during animations specifically logging might have some impact.

That also was made my assumption when I added those logs, but when measured performance then I discovered that it doesn't really affect the performance.

However I don't really like to spam logcat console and reveal details about the app (like which library it does use underhood etc.) so I think the better solution here would be to disable logger in release builds by default (and people always can enable it if needed to capture some data).

kirillzyusko commented 1 week ago

I disabled logging in release in https://github.com/kirillzyusko/react-native-keyboard-controller/pull/577

So release version should be super fast (but debug version also should be pretty fast)!