本文介绍了java.lang.RuntimeException的:无法读取包裹输入通道文件描述符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用crashlytics来跟踪我的应用程序的崩溃。有一个错误这是相当难弄清楚。从crashlytics的堆栈跟踪如下:

I am using crashlytics to track my app's crash. There is one bug which is quite hard to figure out. The stack trace from crashlytics is as below:

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.InputChannel$1.createFromParcel(InputChannel.java:39)
       at android.view.InputChannel$1.createFromParcel(InputChannel.java:36)
       at com.android.internal.view.InputBindResult.<init>(InputBindResult.java:62)
       at com.android.internal.view.InputBindResult$1.createFromParcel(InputBindResult.java:102)
       at com.android.internal.view.InputBindResult$1.createFromParcel(InputBindResult.java:99)
       at com.android.internal.view.IInputMethodManager$Stub$Proxy.windowGainedFocus(IInputMethodManager.java:851)
       at android.view.inputmethod.InputMethodManager.startInputInner(InputMethodManager.java:1292)
       at android.view.inputmethod.InputMethodManager.onWindowFocus(InputMethodManager.java:1518)
       at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3550)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:157)
       at android.app.ActivityThread.main(ActivityThread.java:5293)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
       at dalvik.system.NativeStart.main(NativeStart.java)

我知道有这一个类似的问题here.但有一点不同。而从crashlytics统计,崩溃主要发生在三星的Andr​​oid手机。

I know there is one similar question about this here. But there is a bit different. And as statistics from crashlytics, the crash happens mainly in SAMSUNG android phone.

我是新的Andr​​oid和不知道为什么崩溃发生以及如何修复这种崩溃。

I am new to android and don't know why the crash happened and how to fix this kind of crash.

任何建议将是非常美联社preciated。

Any suggestion would be much appreciated.

推荐答案

认为这是一个非常广泛的领域,并有可能是一个很大的可以触发这个系统级的异常情况。但也许它是如何固定在一个特定的项目这个例子可以帮助别人。

Think it's a very wide area and there could be a lot of situations which can trigger this system level exception. But maybe this example of how it was fixed in a particular project can help someone.

我经历了类似的异常:
无法读取从包裹输入通道文件描述符 三星手机:

I experienced a similar exception:
"Could not read input channel file descriptors from parcel" on Samsung phone:

java.lang.RuntimeException: Could not read input channel file descriptors from parcel.
        at android.view.InputChannel.nativeReadFromParcel(Native Method)
        at android.view.InputChannel.readFromParcel(InputChannel.java:148)
        at android.view.IWindowSession$Stub$Proxy.addToDisplay(IWindowSession.java:690)
        at android.view.ViewRootImpl.setView(ViewRootImpl.java:525)
        at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:269)
        at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
        at android.widget.Toast$TN.handleShow(Toast.java:402)
        at android.widget.Toast$TN$1.run(Toast.java:310)
        at android.os.Handler.handleCallback(Handler.java:730)
        at android.os.Handler.dispatchMessage(Handler.java:92)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:5103)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:525)
        at       com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
        at dalvik.system.NativeStart.main(Native Method)

这事发生在我维护一个大的老项目,仅发生几个小时后,该浮动错误。我花了相当长的一段时间就可以了,也看了一些相关的答案上的SO关于它并没有任何线索,除了它的Andr​​oid的系统级错误,应该还有一些额外的数据或对象或内存等大型物体的副本:

It happened in a big old project which I got for maintenance and this floating bug occurred only after several hours. I spent quite some time on it and also read some related answers on SO regarding it and had no clue except it's a system level bug of Android, and there should be some extra data or duplicates of objects or big objects in memory etc:

<一个href="https://$c$c.google.com/p/android/issues/detail?id=32470">https://$c$c.google.com/p/android/issues/detail?id=32470

过去的事我能想到的是的Soundpool。它不是用了很多的项目 - 有没有玩过不时超过10种不同的声音
但它的根本原因!有时,共有来自的Soundpool浮动异常 无法加载样品(空) 。它有助于认识到的Soundpool是在一个错误的使用方式:

The last thing I could think about was SoundPool. It's not used a lot in the project - there are not more than 10 different sounds played from time to time.
But it was the root cause! Sometimes there were floating exceptions from SoundPool "unable to load sample (null)". And it helped to realize that SoundPool was used in a wrong way:

public void play(int rscId) {
...
    final int soundId = soundPool.load(mContext, rscId, 1);
    ...
    soundPool.play(soundId, volume, volume, 5, 0, 1f);

所以,新的ID生成和声音资源被重新加载,每次应用程序调用播放声音的方法!而一段时间后,一些非相关的例外情况开始出现,直到应用程序崩溃与 无法读取从包裹输入通道文件描述符 异常。照片有趣的是,那些不相关的例外之一是:
ExceptionHandled中无法打开数据库文件(code 14)

So new id was generated and sound resource was reloaded each time application called play sound method! And after certain amount of time some non related exceptions started to occur until application crashed with the "Could not read input channel file descriptors from parcel" exception.
It's interesting that one of those non related exceptions was:
"ExceptionHandled in unable to open database file (code 14)":

ExceptionHandled in unable to open database file (code 14)
android.database.sqlite.SQLiteCantOpenDatabaseException: 
unable to open database file (code 14)
at android.database.sqlite.SQLiteConnection.nativeExecuteForCursorWindow
(Native Method)
at android.database.sqlite.SQLiteConnection.executeForCursorWindow
(SQLiteConnection.java:845)

当然这无关既不数据库也不符合祝酒词/包裹。对于特殊情况的修复很简单:只需$因为它建议在Android的文献P $ PLOAD所有的声音:

And of course it has nothing to do neither with database nor with toasts/parcels. The fix for that particular situation was very easy: just preload all sounds as it's suggested in Android documentation:

http://developer.android.com/reference/android/media/SoundPool.html

,通过声音调用相应的 SoundPool.load()函数列表加载逻辑,迭代,这通常应该在流程早期完成,以便有时间DECOM $ P $需要才进行播放pssing音频原始PCM格式。
一旦声音加载和播放已启动,应用程序可以通过调用触发声音 SoundPool.play()

"The loading logic iterates through the list of sounds calling the appropriate SoundPool.load() function. This should typically be done early in the process to allow time for decompressing the audio to raw PCM format before they are needed for playback.
Once the sounds are loaded and play has started, the application can trigger sounds by calling SoundPool.play()."

所以,我感动 soundPool.load()从play()方法和异常:
无法读取从包裹输入通道文件描述符已经和异常无法打开数据库文件(code 14)

So I moved soundPool.load() out from play() method and the exception :
"Could not read input channel file descriptors from parcel" has gone as well as the exception "unable to open database file (code 14)".

public void play(int soundId) {
    ...
    soundPool.play(soundId, volume, volume, 5, 0, 1f);

soundPool.release();的Soundpool = NULL 当它不再需要应该被称为好。也许它也可以对这些异常的效果,详情请参阅此处

And soundPool.release(); soundPool = null should be called as well when it's not needed anymore. And maybe it also can have an effect on such exceptions, see details here

Could看不懂的包裹输入通道文件描述符

最有可能它不是原来问题的具体情况,但希望它可以提供一些信息,以进一步挖掘。即寻找一些其他例外,吞噬异常或错误的文件/数据处理。

Most probably it's not the exact situation for the original question but hope it can give some information to dig further. I.e. looking for some additional exceptions, swallowed exceptions, or wrong files/data handling.

这篇关于java.lang.RuntimeException的:无法读取包裹输入通道文件描述符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 09:59