在我的应用程序中,我周期性地用WebView
调用fragment,以显示PowerBi
数据一段时间。首次调用片段时,分析器显示该应用程序使用了大约+ 60MB的内存。而且每次调用一次又一次时,它将占用+ 30MB的内存。我认为应用程序不会覆盖网页数据,而是将其存储到缓存中。
mWebView = view.findViewById(R.id.webView);
mWebView.setWebViewClient(new WebViewClient());
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setDomStorageEnabled(true);
mWebView.setOverScrollMode(WebView.OVER_SCROLL_NEVER);
mWebView.loadUrl("https://mylink");
这是堆栈跟踪:
[ERROR:gles2_cmd_decoder.cc(2009)] [GroupMarkerNotSet(crbug.com/242999)!:7C501C92]GL ERROR :GL_INVALID_OPERATION : BackFramebuffer::Destroy: <- error from previous GL command
I/art: Thread[2,tid=4307,WaitingInMainSignalCatcherLoop,Thread*=0xae442000,peer=0x12c7d0a0,"Signal Catcher"]: reacting to signal 3
I/art: Wrote stack traces to '/data/anr/traces.txt'
好吧,我已经创建了CountDownTimer
并设置了几行要在WebView
的末尾执行的代码。我加了:
mWebView.clearCache(true);
mWebView.destroy();
仍然,当应用程序运行了一整夜后,它崩溃了。 这是堆栈跟踪:
W/InputMethodManager: IME died: com.android.inputmethod.latin/.LatinIME
android.os.DeadObjectException
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:503)
at com.android.internal.view.IInputMethodManager$Stub$Proxy.windowGainedFocus(IInputMethodManager.java:732)
at android.view.inputmethod.InputMethodManager.startInputInner(InputMethodManager.java:1226)
at android.view.inputmethod.InputMethodManager.onPostWindowFocus(InputMethodManager.java:1445)
at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3386)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
E/RingtonePlayService: onStartCommand started.
D/RingtonePlayService: lunch break should end now
no active alarms
D/EGL_emulation: eglMakeCurrent: 0x86b14060: ver 2 0 (tinfo 0x9dfa0190)
D/EGL_emulation: eglMakeCurrent: 0x86b14660: ver 2 0 (tinfo 0x9dfa0190)
D/EGL_emulation: eglMakeCurrent: 0x86b14060: ver 2 0 (tinfo 0x9dfa0190)
E/Surface: queueBuffer: error queuing buffer to SurfaceTexture, -19
E/EGL_emulation: tid 3833: swapBuffers(531): error 0x300d (EGL_BAD_SURFACE)
W/OpenGLRenderer: swapBuffers encountered EGL_BAD_SURFACE on 0x91c25720, halting rendering...
D/EGL_emulation: eglMakeCurrent: 0xae415260: ver 2 0 (tinfo 0xae412a70)
D/EGL_emulation: eglCreateContext: 0x86b14060: maj 2 min 0 rcv 2
D/EGL_emulation: eglMakeCurrent: 0x86b14060: ver 2 0 (tinfo 0x9dfa0190)
E/Surface: getSlotFromBufferLocked: unknown buffer: 0x8a1fad20
D/EGL_emulation: eglCreateContext: 0x86b14660: maj 2 min 0 rcv 2
D/EGL_emulation: eglMakeCurrent: 0x86b14660: ver 2 0 (tinfo 0x9dfa0190)
W/BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 3785
Application terminated.
这是Crashlytics
中相同崩溃的代码:
Fatal Exception: java.lang.RuntimeException: Could not read input channel file descriptors from parcel.
at android.view.InputChannel.nativeReadFromParcel(InputChannel.java)
at android.view.InputChannel.readFromParcel(InputChannel.java:148)
at android.view.IWindowSession$Stub$Proxy.addToDisplay(IWindowSession.java:841)
at android.view.ViewRootImpl.setView(ViewRootImpl.java:812)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:351)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3594)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2795)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1527)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6251)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
我不确定问题出在哪里以及如何解决。