helloworld1 / AnyMemo

Advanced Spaced Repetition flashcard learning software for Android.
http://www.anymemo.org
GNU General Public License v2.0
151 stars 53 forks source link

window leak with dialogs #486

Open anlalalu opened 4 years ago

anlalalu commented 4 years ago

dialog still exist.

Actual Result

The dialog disappears with the stack trace:

E/WindowManager: android.view.WindowLeaked: Activity org.liberty.android.fantastischmemo.ui.PreviewEditActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{5286d634 V.E..... R....... 0,0-729,390} that was originally added here at android.view.ViewRootImpl.(ViewRootImpl.java:346) at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:248) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69) at android.app.Dialog.show(Dialog.java:286) at org.liberty.android.fantastischmemo.ui.PreviewEditActivity.deleteCard(PreviewEditActivity.java:583) at org.liberty.android.fantastischmemo.ui.PreviewEditActivity.onOptionsItemSelected(PreviewEditActivity.java:285) at android.app.Activity.onMenuItemSelected(Activity.java:2600) at androidx.fragment.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:436) at androidx.appcompat.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:196) at androidx.appcompat.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:109) at androidx.appcompat.app.AppCompatDelegateImpl.onMenuItemSelected(AppCompatDelegateImpl.java:888) at androidx.appcompat.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:840) at androidx.appcompat.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:158) at androidx.appcompat.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:991) at androidx.appcompat.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:981) at androidx.appcompat.widget.ActionMenuView.invokeItem(ActionMenuView.java:625) at androidx.appcompat.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:151) at android.view.View.performClick(View.java:4438) at android.view.View$PerformClick.run(View.java:18422) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5001) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) at dalvik.system.NativeStart.main(Native Method)

Debug info

App Version = 10.11.3

Android Version = 4.4.4

This maybe solved with reference to this: https://stackoverflow.com/questions/2850573/activity-has-leaked-window-that-was-originally-added

anlalalu commented 4 years ago

There are other similar bugs which are often triggered with rotating operation.

Reproduction Steps
  1. click an item in list
  2. tap 'search'
  3. rotate the screen
Stack Trace

E/WindowManager: android.view.WindowLeaked: Activity org.liberty.android.fantastischmemo.ui.StudyActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{52a57330 V.E..... R....... 0,0-729,682} that was originally added here at android.view.ViewRootImpl.(ViewRootImpl.java:346) at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:248) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69) at android.app.Dialog.show(Dialog.java:286) at android.app.AlertDialog$Builder.show(AlertDialog.java:951) at org.liberty.android.fantastischmemo.utils.DictionaryUtil.showLookupListDialog(DictionaryUtil.java:100) at org.liberty.android.fantastischmemo.ui.StudyActivity.lookupDictionary(StudyActivity.java:711) at org.liberty.android.fantastischmemo.ui.StudyActivity.onOptionsItemSelected(StudyActivity.java:214) at android.app.Activity.onMenuItemSelected(Activity.java:2600) at androidx.fragment.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:436) at androidx.appcompat.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:196) at androidx.appcompat.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:109) at androidx.appcompat.app.AppCompatDelegateImpl.onMenuItemSelected(AppCompatDelegateImpl.java:888) at androidx.appcompat.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:840) at androidx.appcompat.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:158) at androidx.appcompat.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:991) at androidx.appcompat.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:981) at androidx.appcompat.widget.ActionMenuView.invokeItem(ActionMenuView.java:625) at androidx.appcompat.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:151) at android.view.View.performClick(View.java:4438) at android.view.View$PerformClick.run(View.java:18422) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5001) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) at dalvik.system.NativeStart.main(Native Method)

anlalalu commented 4 years ago
Stack Trace

E/WindowManager(21336): E/WindowManager(21336): android.view.WindowLeaked: Activity org.liberty.android.fantastischmemo.downloader.quizlet.QuizletSearchByUsernameActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{52a33ad8 V.E..... R....... 0,0-729,518} that was originally added here E/WindowManager(21336): at android.view.ViewRootImpl.(ViewRootImpl.java:346) E/WindowManager(21336): at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:248) E/WindowManager(21336): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69) E/WindowManager(21336): at android.app.Dialog.show(Dialog.java:286) E/WindowManager(21336): at android.app.AlertDialog$Builder.show(AlertDialog.java:951) E/WindowManager(21336): at org.liberty.android.fantastischmemo.downloader.quizlet.QuizletSearchByUsernameActivity.showSearchUserDialog(QuizletSearchByUsernameActivity.java:58) E/WindowManager(21336): at org.liberty.android.fantastischmemo.downloader.quizlet.QuizletSearchByUsernameActivity.onCreate(QuizletSearchByUsernameActivity.java:28) E/WindowManager(21336): at android.app.Activity.performCreate(Activity.java:5231) E/WindowManager(21336): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) E/WindowManager(21336): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148) E/WindowManager(21336): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) E/WindowManager(21336): at android.app.ActivityThread.access$800(ActivityThread.java:135) E/WindowManager(21336): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) E/WindowManager(21336): at android.os.Handler.dispatchMessage(Handler.java:102) E/WindowManager(21336): at android.os.Looper.loop(Looper.java:136) E/WindowManager(21336): at android.app.ActivityThread.main(ActivityThread.java:5001) E/WindowManager(21336): at java.lang.reflect.Method.invokeNative(Native Method) E/WindowManager(21336): at java.lang.reflect.Method.invoke(Method.java:515) E/WindowManager(21336): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) E/WindowManager(21336): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) E/WindowManager(21336): at dalvik.system.NativeStart.main(Native Method)