capacitor-community / safe-area

Capacitor Plugin that exposes the safe area insets from the native iOS/Android device to your web project.
MIT License
49 stars 15 forks source link

Plugin makes app unresponsive on Android #25

Closed frederikheld closed 1 week ago

frederikheld commented 1 month ago

Describe the bug

My app is very unresponsive to user input on Android and I narrowed it down to this plugin. The app also has severe issues when the visible area has to be resized due to opening/closing of the soft keyboard, which seems to be a familiar issue (see #24). It can often take many seconds after the keyboard was closed that the app actually resizes to the newly available space.

Looking at LogCat, I see a constant stream of info messages that appear to be coming from this plugin:

2024-07-22 02:05:05.411  6322-6358  chromium                com.google.android.webview           I  [INFO:document_style_environment_variables.cc(104)] E2E_Used SafeAreaInsetBottom
2024-07-22 02:05:05.422  6322-6358  chromium                com.google.android.webview           I  [INFO:document_style_environment_variables.cc(104)] E2E_Used SafeAreaInsetBottom
2024-07-22 02:05:05.433  6322-6358  chromium                com.google.android.webview           I  [INFO:document_style_environment_variables.cc(104)] E2E_Used SafeAreaInsetBottom
2024-07-22 02:05:05.444  6322-6358  chromium                com.google.android.webview           I  [INFO:document_style_environment_variables.cc(104)] E2E_Used SafeAreaInsetBottom
2024-07-22 02:05:05.454  6322-6358  chromium                com.google.android.webview           I  [INFO:document_style_environment_variables.cc(104)] E2E_Used SafeAreaInsetBottom
2024-07-22 02:05:05.466  6322-6358  chromium                com.google.android.webview           I  [INFO:document_style_environment_variables.cc(104)] E2E_Used SafeAreaInsetBottom
2024-07-22 02:05:05.476  6322-6358  chromium                com.google.android.webview           I  [INFO:document_style_environment_variables.cc(104)] E2E_Used SafeAreaInsetBottom
2024-07-22 02:05:05.488  6322-6358  chromium                com.google.android.webview           I  [INFO:document_style_environment_variables.cc(104)] E2E_Used SafeAreaInsetBottom

This is only a very small amount of those messages. You can see from the timestamps how frequent they come.

The laggy responsiveness was especially bad with alpha.3. Now I have updated to alpha.6, the responsiveness seems to be improved. But the stream of messages is still there and the safe area inset bottom is does not seem to work anymore. Inset top still works though.

Note: downgrading to alpha.5 fixed the missing inset bottom and also seems to fix the lag. Messages still there as well.

Screenshots If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

tafelnl commented 1 month ago

Are you testing the app on a physical device? And are you using a production build? The latter can make a huge difference in performance. I haven't experienced any performance issues (yet) myself.

Note: downgrading to alpha.5 fixed the missing inset bottom and also seems to fix the lag. Messages still there as well.

This is weird, because if you look at the diff, there's not something that points to such a behavior change. The same exact padding values are injected into the client. Also it's hard to imagine that just this line:

val imeHeight = imeInsets.bottom - systemBarsInsets.bottom

would cause a major difference in performance

tafelnl commented 1 month ago

Please let me know if you are still experiencing issues with this. It would be very helpful

tafelnl commented 1 week ago

Closing because issue has gone stale