6

I am seeing this error getting reported in my logging software but cant determine what is causing it, or what the 300 limit is referring to... the number of views or possibly items displayed in a list...

This is all i could pull from my log:

window count is over max 300
android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:430)
android.view.WindowManagerImpl.addView(WindowManagerImpl.java:133)
android.widget.PopupWindow.invokePopup(PopupWindow.java:1688)
android.widget.PopupWindow.showAtLocation(PopupWindow.java:1408)
android.widget.PopupWindow.showAtLocation(PopupWindow.java:1374)

I did some research and a bunch of debugging on any Dialog or PopupWindow but cant recreate this. Any ideas or suggestions would be appreciated.

EDIT I was able to pull another occurrence of this issue with a different stacktrace...

window count is over max 300 
android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:430)
android.view.WindowManagerImpl.addView(WindowManagerImpl.java:133)
android.app.ActivityThread.handleResumeActivity(ActivityThread.java:5322)
android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:54)
android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:2438)
android.os.Handler.dispatchMessage(Handler.java:106)
android.os.Looper.loopOnce(Looper.java:226)
android.os.Looper.loop(Looper.java:313)
android.app.ActivityThread.main(ActivityThread.java:8663)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

EDIT 2

This appears to only be happening on Android 12 OS

EDIT 3

This appears to also be happening on Android 13 with a slightly different error message

window count is over max!!
RH201
  • 312
  • 3
  • 16
  • Do you use `Toast`? – CommonsWare Jun 15 '22 at 21:18
  • @CommonsWare Yes there are a few functions throughout the app that will show a Toast, but they are not used very often at all. – RH201 Jun 16 '22 at 17:39
  • 1
    Could you solve this issue? I am getting the same stracktrace that you post in EDIT 1 and only in Android 12. – César Ynga Oct 27 '22 at 18:32
  • 1
    @CésarYnga No solution yet. Opened a Bug report in the Android issue Tracker https://issuetracker.google.com/issues/260731729... we'll see if it gets anywhere – RH201 Nov 29 '22 at 18:26
  • I also get this stacktrace like in edit 3 (window count is over max!!) since december '22. Android Dolphin | 2021.3.1 Patch 1, targetSdkVersion 33. On Device Android 13 (SDK 33) – guenter47 Dec 26 '22 at 22:31
  • Same here, happening on Android 13 only, with crash message "Window count is over max!!" – Jorn Rigter Feb 08 '23 at 17:49
  • Created a [bug report in Issue Tracker](https://issuetracker.google.com/issues/268299881), please upvote if relevant so we can find a fix soon – Jorn Rigter Feb 08 '23 at 18:00
  • Kindly let us know if you figured it out – code ketty Apr 02 '23 at 17:25
  • I dont have much of an update, but this does appear to be related to some kind of Dialog and a new app session beginning after a few hours of no activity. Does anyone else having this issue use any kind of Dialog style/theme. For example, i use – RH201 Apr 20 '23 at 14:09
  • @RH201 finally got it fixed but I did many changes so first let me ask you if you use billing or window overlay in a service? – code ketty May 21 '23 at 06:55

2 Answers2

2

I run into exactly the same issue as you. For my case it was not a bug but a badly written code, where it ended up creating hundreds of dialog. Simply speaking it went to infinite loop.

Not sure if that will help you but what caused the error for me was when the activity was destroyed by the system (it happened only on few kind of Samsung devices). Then, when user bring the app back to life, this created duplicate viewModel with duplicate listeners etc.. It all went mad.

So my guess is your app is either not cleaning properly something or by any other way it get trapped in infinite loop creating hundreds of those dialogs and windows. Check what is happening in your code around those lines. There is no simple solution to this.

Roman
  • 21
  • 5
  • This makes sense with what i see in the logs for this issue. The app always crashes early in the life cycle, almost as soon as it is started. So there may be some dialog or possibly a countdown that is not being killed properly when the app is closed. I will do some testing with LeakCanary and see if i can isolate any leaks after the app is killed. – RH201 Mar 02 '23 at 14:31
-1

I am not sure you are still facing this issue.

Actually this happens when you are opening Windows more than 300.

Check if there is any such for or infinite loop.

Abhnav Maurya
  • 115
  • 1
  • 4