活动空闲超时时间为ActivityRecord [英] Activity Idle Timeout for ActivityRecord

查看:2347
本文介绍了活动空闲超时时间为ActivityRecord的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我有一个奇怪的问题,我不完全知道所有的信息,我应该提供的,但我会尽我所能 - 只是让我知道,如果我需要增加更多的信息。我有一个问题,当我完成我的活动并返回到previous 活动(或启动用新的意图 - 这个问题似乎就完成了的活动为中心)的UI性能急剧下降的约六,七秒钟,然后恢复正常。

So I have a strange problem, and I'm not entirely sure what all information I should provide, but I'll do my best -- just let me know if I need to add more info. I'm having an issue that when I finish my Activity and return to the previous Activity (or launch it with a new Intent -- the problem seems to be centered on finishing the Activity) the UI performance drops drastically for about six or seven seconds, then returns to normal.

LogCat中,这样的警告不断出现的:

From LogCat, this warning appears consistently:

07-11 22:09:42.594: W/ActivityManager(292): Launch timeout has expired, giving up wake lock!
07-11 22:09:42.601: W/ActivityManager(292): Activity idle timeout for ActivityRecord{42bf6e00 com.kcoppock.sudokubeta/com.kcoppock.sudoku.SudokuBoardActivity}

一旦活动超时,用户界面​​的性能恢复正常。直到那一点上是非常缓慢。我没有code,我知道这可能是阻塞主线程,我甚至走了这么远,注释掉我的整个的onPause()方法,看它是否有什么差别,并且它不

As soon as the activity times out, UI performance returns to normal. Until that point it is very sluggish. I have no code that I am aware of that could be blocking the main thread, and I've even gone so far as to comment out my entire onPause() method to see if it makes any difference, and it does not.

活动不产卵任何后台线程,不执行任何网络活动,它具有唯一的磁盘访问共享$的一些访问p $ pferences 。在previous问题,我已经能够找到的关于闲置超时 HistoryRecord ,不是 ActivityRecord

The Activity does not spawn any background threads, does not perform any network activity, the only disk access it has is some accessing of SharedPreferences. The previous questions I've been able to locate are about idle timeouts for HistoryRecord, not ActivityRecord.

任何想法什么会导致此?或者,我怎么能去决定什么是阻塞UI线程,如果这是发生了什么事?

Any ideas what would cause this? Or how I could go about determining what is blocking the UI thread, if that is what is happening?

修改:好吧,只是尝试注释掉的所有的除外super.onCreate()和的setContentView() - 问题仍然存在。它不与任何其他活动,但是这一次发生,但有没什么好这一个。 :/

EDIT : Okay, just tried commenting out everything except super.onCreate() and setContentView() -- the problem still persists. It doesn't occur with any other Activities but this one, but there's NOTHING TO this one. :/

推荐答案

哦天啊。其中的一个东西,是pretty的努力尝试和错误的诊断外,但我已经想通了。作为参考,任何人都应该有这个问题,它来到了我的布局中的自定义视图。我增加了一个 ViewTreeObserver.OnGlobalLayoutListener()做布局传递经过一番布置的修改,但听众中我修改了布局,从而引起另一个布局,基本上是建立一个无限环(但不知何故没有引起ANR)。我的解决办法是,像这样:

Oh geez. One of those things that's pretty hard to diagnose outside of trial and error, but I've figured it out. For reference, should anyone else have this problem, it came down to a custom view in my layout. I had added a ViewTreeObserver.OnGlobalLayoutListener() to do some layout modifications after the layout pass, but within that listener I modified the layout and thus caused another layout, essentially creating an infinite loop (but somehow not causing an ANR). My solution was like so:

private class BoardLayoutListener implements OnGlobalLayoutListener {
    @Override
    public void onGlobalLayout() {
        //...do stuff here

        //REMOVE this listener so that you don't repeat this forever
        ViewTreeObserver obs = SudokuBoard.this.getViewTreeObserver();
        obs.removeGlobalOnLayoutListener(this);
    }
}

这个解决方案是非常具有讽刺意味的​​,考虑到我的<一个href="http://stackoverflow.com/questions/4142090/how-do-you-to-retrieve-dimensions-of-a-view-getheight-and-getwidth-always-r/4406090#4406090">second计算器上收视率最高的答案专门处理这一点。 :P

This solution is quite ironic, considering my second highest rated answer on StackOverflow specifically deals with this. :P

叹息

这篇关于活动空闲超时时间为ActivityRecord的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆