Skip to content

perf: don't change currentKeyboardFrame each frame#1381

Merged
kirillzyusko merged 1 commit intomainfrom
fix/do-not-change-keyboard-frame-each-frame
Mar 19, 2026
Merged

perf: don't change currentKeyboardFrame each frame#1381
kirillzyusko merged 1 commit intomainfrom
fix/do-not-change-keyboard-frame-each-frame

Conversation

@kirillzyusko
Copy link
Copy Markdown
Owner

@kirillzyusko kirillzyusko commented Mar 19, 2026

📜 Description

Don't change keyboard padding in KeyboardAwareScrollView each frame as keyboard moves and do it only in the beginning of the animation (when keyboard appears) or in the end of the animation (when keyboard closed).

💡 Motivation and Context

After #797 introduced removal of ghost padding we don't need to change inset every frame. Instead we can use an optimized approach and:

  • add full keyboard frame padding only in the beginning of the animation (when keyboard appears)
  • remove full keyboard frame padding when keyboard fully closed.

Roughly it gives us 2x less load on UI thread because now we only need to adjust scroll position inside onMove handler. A similar approach is already used in KeyboardChatScrollView (we also change padding only one time there). So these changes just makes components consistent.

📢 Changelog

JS

  • don't change currentKeyboardFrame each frame;

🤔 How Has This Been Tested?

Tested manually on iPhone 17 Pro (iOS 26.2, simulator), Pixel 7 Pro (API 36, real device).

📸 Screenshots (if appropriate):

iOS Android
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-03-19.at.10.55.30.mov
telegram-cloud-document-2-5323806589835054340.mp4

📝 Checklist

  • CI successfully passed
  • I added new mocks and corresponding unit-tests if library API was changed

@kirillzyusko kirillzyusko self-assigned this Mar 19, 2026
@kirillzyusko kirillzyusko added 🚀 optimization You optimize something and it becomes working faster KeyboardAwareScrollView 📜 Anything related to KeyboardAwareScrollView component labels Mar 19, 2026
@github-actions
Copy link
Copy Markdown
Contributor

📊 Package size report

Current size Target Size Difference
306910 bytes 306909 bytes 1 bytes 📈

@kirillzyusko kirillzyusko marked this pull request as ready for review March 19, 2026 10:01
@kirillzyusko kirillzyusko merged commit bba6afc into main Mar 19, 2026
16 checks passed
@kirillzyusko kirillzyusko deleted the fix/do-not-change-keyboard-frame-each-frame branch March 19, 2026 10:10
kirillzyusko added a commit that referenced this pull request Mar 21, 2026
## 📜 Description

Call `syncKeyboardFrame` after `keyboardHeight` has been set.

## 💡 Motivation and Context

If we set call `syncKeyboardFrame` and `keyboardHeight = 0`, then
interpolation simply doesn't work we interpolate between `[0, 0]` to
`[0, 0]`, so we get `0`. This regression has been introduced after
#1381
changes and in this follow-up PR I'm fixing it 🤞

The fix is quite straightforward - we just need to call
`syncKeyboardFrame` after updating `keyboardHeight` variable.

Closes
#1385

## 📢 Changelog

<!-- High level overview of important changes -->
<!-- For example: fixed status bar manipulation; added new types
declarations; -->
<!-- If your changes don't affect one of platform/language below - then
remove this platform/language -->

### JS

- call `syncKeyboardFrame` after `keyboardHeight` has been set.

## 🤔 How Has This Been Tested?

Tested manually on iPhone 17 Pro (iOS 26.2).

## 📸 Screenshots (if appropriate):

|Before|After|
|-------|-----|
|<video
src="https://github.com/user-attachments/assets/70e2fef8-81b0-455d-b877-98067dfd3965">|<video
src="https://github.com/user-attachments/assets/08113d77-89b3-4b42-8d0e-f6334c05c602">|

## 📝 Checklist

- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed
@kirillzyusko kirillzyusko mentioned this pull request Mar 23, 2026
2 tasks
kirillzyusko added a commit that referenced this pull request Mar 23, 2026
## 📜 Description

Removed a fix with increased padding by `+1`.

## 💡 Motivation and Context

This code has been added in
#342
But these changes became irrelevant after
#1381
Since we started to change frame to full-height frame once per the
animation we no longer have a condition described in #342

Additionally
#332
is no longer reproducible, because in
#797
we already were fighting with "ghost view" issue and fix for this
problem also fixes
#332
(just in a different way).

So to sum it up:
- we no longer need to adjust spacer each frame;
- we no longer need a fix with artificial spacer increasing 🤞 

## 📢 Changelog

<!-- High level overview of important changes -->
<!-- For example: fixed status bar manipulation; added new types
declarations; -->
<!-- If your changes don't affect one of platform/language below - then
remove this platform/language -->

### JS

- don't apply `+1` to keyboard spacer size in `KeyboardAwareScrollView`;

## 🤔 How Has This Been Tested?

Tested manually on Redmi Note 5 Pro (Android 9).

## 📸 Screenshots (if appropriate):

|Current code|Latest main (before PR changes)|1.20.7 release|
|-------------|---------------------------------|-------------|
|<video
src="https://github.com/user-attachments/assets/7ab3477c-eedd-42da-9af9-5bdb0c842284">|<video
src="https://github.com/user-attachments/assets/8697e5e6-84d3-49c5-adb6-2d286cd9ccaa">|<video
src="https://github.com/user-attachments/assets/37c9b30c-8aa8-470a-9255-8c4a3d752a95">|

## 📝 Checklist

- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

KeyboardAwareScrollView 📜 Anything related to KeyboardAwareScrollView component 🚀 optimization You optimize something and it becomes working faster

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant