Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WindowManager: android.view.WindowLeaked #498

Closed
Crare opened this issue Oct 18, 2023 · 4 comments
Closed

WindowManager: android.view.WindowLeaked #498

Crare opened this issue Oct 18, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@Crare
Copy link

Crare commented Oct 18, 2023

Bug summary

Hi! Got error on Android API level 25 (Android 7.1.1) emulator.
This works fine on newer android API level 33.

using react-native 0.72.4.

we get this error in adb logcat:

10-18 15:23:45.691 21590 21590 E WindowManager: 
10-18 15:23:45.691 21590 21590 E WindowManager: android.view.WindowLeaked: Activity com.foobar.foobarapp.MainActivity has leaked window DecorView@d90b893[] that was originally added here
10-18 15:23:45.691 21590 21590 E WindowManager: 	at android.view.ViewRootImpl.<init>(ViewRootImpl.java:418)
10-18 15:23:45.691 21590 21590 E WindowManager: 	at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:331)
10-18 15:23:45.691 21590 21590 E WindowManager: 	at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
10-18 15:23:45.691 21590 21590 E WindowManager: 	at android.app.Dialog.show(Dialog.java:322)
10-18 15:23:45.691 21590 21590 E WindowManager: 	at com.zoontek.rnbootsplash.RNBootSplashModuleImpl.showDialog(RNBootSplashModuleImpl.java:63)
10-18 15:23:45.691 21590 21590 E WindowManager: 	at com.zoontek.rnbootsplash.RNBootSplashModuleImpl.-$$Nest$smshowDialog(RNBootSplashModuleImpl.java)
10-18 15:23:45.691 21590 21590 E WindowManager: 	at com.zoontek.rnbootsplash.RNBootSplashModuleImpl$5.run(RNBootSplashModuleImpl.java:166)
10-18 15:23:45.691 21590 21590 E WindowManager: 	at android.os.Handler.handleCallback(Handler.java:751)
10-18 15:23:45.691 21590 21590 E WindowManager: 	at android.os.Handler.dispatchMessage(Handler.java:95)
10-18 15:23:45.691 21590 21590 E WindowManager: 	at android.os.Looper.loop(Looper.java:154)
10-18 15:23:45.691 21590 21590 E WindowManager: 	at android.app.ActivityThread.main(ActivityThread.java:6119)
10-18 15:23:45.691 21590 21590 E WindowManager: 	at java.lang.reflect.Method.invoke(Native Method)
10-18 15:23:45.691 21590 21590 E WindowManager: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
10-18 15:23:45.691 21590 21590 E WindowManager: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

Library version

5.0.4

Environment info

System:
  OS: macOS 13.6
  CPU: (10) arm64 Apple M1 Max
  Memory: 408.52 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.8.1
    path: /var/folders/jv/vgxybjb50cq62gfjwnfp386c0000gn/T/yarn--1697632897504-0.23897261438769646/node
  Yarn:
    version: 1.22.19
    path: /var/folders/jv/vgxybjb50cq62gfjwnfp386c0000gn/T/yarn--1697632897504-0.23897261438769646/yarn
  npm:
    version: 10.1.0
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2023.10.09.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.12.1
    path: /Users/<username>/.rvm/gems/ruby-2.7.5/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.0
      - iOS 17.0
      - macOS 14.0
      - tvOS 17.0
      - watchOS 10.0
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.3 AI-223.8836.35.2231.10811636
  Xcode:
    version: 15.0/15A240d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.20.1
    path: /usr/bin/javac
  Ruby:
    version: 2.7.5
    path: /Users/<username>/.rvm/rubies/ruby-2.7.5/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.4
    wanted: 0.72.4
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Steps to reproduce

  1. use android api level 25.(Android 7.1.1.) emulator. I used device: Nexus 4 API 25, arm64, with Google APIs.
  2. use react-native 0.72.4
  3. ...

Reproducible sample code

I tried to do a separate project with just including package react-native-bootsplash and setting it up, but didn't get the error that time. It worked just fine. Our project uses react-navigation-npm package. We changed the app to use smaller splashscreen images as we got some out of memory exceptions. Those do happen sometimes still.

If the splashscreen images were SVG-files, they would use a lot less space too, but they are converted to PNGs.(probably because backwards combatibility or how Android SplashScreen just works?)
@Crare Crare added the bug Something isn't working label Oct 18, 2023
@zoontek
Copy link
Owner

zoontek commented Oct 18, 2023

I tried to do a separate project with just including package react-native-bootsplash and setting it up, but didn't get the error that time. It worked just fine. Our project uses react-navigation-npm package. We changed the app to use smaller splashscreen images as we got some out of memory exceptions. Those do happen sometimes still.

If you cannot reproduce it easily, this could also be because of something else in your stack.

If the splashscreen images were SVG-files, they would use a lot less space too, but they are converted to PNGs.(probably because backwards combatibility or how Android SplashScreen just works?)

Nah, PNGs impact here is really minor.

As I remember, this error could occur when the Activity is already exited and the splashscreen sequence not finished (the Activity was destroyed before the Dialog) which result in…nothing for the user. Sure, it adds pollution in the log, that's why having a good way to reproduce it could help removing it.

Example: Another package makes your app make crashes at start. The splash screen sequence fail, this error appear.

@zoontek zoontek mentioned this issue Nov 1, 2023
@zoontek
Copy link
Owner

zoontek commented Nov 1, 2023

@Crare Should be fixed with #505

@Crare
Copy link
Author

Crare commented Nov 1, 2023

Very nice! I'll try it out as soon as I can. maybe already tomorrow.

@Crare
Copy link
Author

Crare commented Nov 2, 2023

@zoontek that seems to get rid of the error android.view.WindowLeaked error. Thanks!
we do have other packages though that seem to still break it, but for this part it is ok now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants