programing

java.lang.RuntimeException : Parcel에서 입력 채널 파일 설명자를 읽을 수 없습니다.

projobs 2021. 1. 16. 09:14
반응형

java.lang.RuntimeException : Parcel에서 입력 채널 파일 설명자를 읽을 수 없습니다.


내 앱의 충돌을 추적하기 위해 crashlytics를 사용하고 있습니다. 알아 내기 어려운 버그가 하나 있습니다. crashlytics의 스택 추적은 다음과 같습니다.

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)

여기에 비슷한 질문이 하나 있다는 것을 알고 있습니다 . 그러나 약간 다릅니다. 그리고 crashlytics의 통계로서 충돌은 주로 삼성 안드로이드 폰에서 발생합니다.

나는 안드로이드를 처음 사용하고 충돌이 발생한 이유와 이러한 종류의 충돌을 해결하는 방법을 모릅니다.

어떤 제안이라도 대단히 감사하겠습니다.


매우 넓은 영역이며이 시스템 수준 예외를 트리거 할 수있는 많은 상황이있을 수 있습니다. 그러나 특정 프로젝트에서 수정 된 방법에 대한이 예가 누군가에게 도움이 될 수 있습니다.

비슷한 예외가 발생했습니다.
"Could not read input channel file descriptors from parcel"삼성 전화에서 :

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)

유지 보수를 위해 얻은 큰 오래된 프로젝트에서 발생 했으며이 부동 버그는 몇 시간 후에 발생했습니다. 나는 그것에 꽤 많은 시간을 보냈고 그것에 관한 몇 가지 관련 답변을 읽었으며 Android의 시스템 수준 버그를 제외하고는 실마리가 없었으며 메모리에 추가 데이터 또는 개체 또는 큰 개체의 중복이 있어야합니다.

https://code.google.com/p/android/issues/detail?id=32470

마지막으로 생각할 수 있었던 것은 SoundPool이었습니다. 프로젝트에서 많이 사용되지는 않습니다. 때때로 재생되는 사운드는 10 개 이하입니다.
그러나 그것이 근본 원인이었습니다! 때때로 SoundPool에서 부동 예외가 발생했습니다 "unable to load sample (null)". 그리고 SoundPool이 잘못된 방식으로 사용되었다는 사실을 깨닫게되었습니다.

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

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)

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

"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()."

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);

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 not read input channel file descriptors from parcel

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.


I am looking for the answer for a long time such as the others facing at this exception.

As I see it, this crash can also be triggered by the unexceptional TextView or EditText which works with the InputMethodManager:

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.InputChannel$1.createFromParcel(InputChannel.java:39)
    at android.view.InputChannel$1.createFromParcel(InputChannel.java:36)
    at com.android.internal.view.InputBindResult.<init>(InputBindResult.java:68)
    at com.android.internal.view.InputBindResult$1.createFromParcel(InputBindResult.java:112)
    at com.android.internal.view.InputBindResult$1.createFromParcel(InputBindResult.java:109)
    at com.android.internal.view.IInputMethodManager$Stub$Proxy.startInput(IInputMethodManager.java:697)
    at android.view.inputmethod.InputMethodManager.startInputInner(InputMethodManager.java:1407)
    at android.view.inputmethod.InputMethodManager.checkFocus(InputMethodManager.java:1518)
    at android.view.inputmethod.InputMethodManager.restartInput(InputMethodManager.java:1286)
    at android.widget.TextView.setText(TextView.java:4718)
    at android.widget.TextView.setText(TextView.java:4656)
    at android.widget.TextView.append(TextView.java:4330)
    at android.widget.TextView.append(TextView.java:4320)
    ...

When TextView appending text, it will make text to Editable, and start InputMethodManager. But at this time, something goes wrong in the InputMethod process, and it leads to fail to create InputBindResult which reading error from the parcel.

In this case, the workaround is very simple: DO NOT call append on textview directly, use StringBuilder or SpannableStringBuilder to build text and call TextView.setText(text) instead!


Previous users have commented that this can be a hard bug to track down. I caused this by building a custom alert dialog (containing multiple TextView objects) inside of a while loop vice an if statement. The application crashed before displaying the dialog box(es).


I have meet this problem recently.

java.lang.RuntimeException: Could not read input channel file descr
iptors from parcel.

I search the log find following info:

01-01 09:07:52.164 5162 6777 W zygote64: ashmem_create_region failed for 'indirect ref table': Too many open files

The problem is that I create HandlerThread repeatedly, but don't do it's quit() method, at last result in fd leaked.


I got this error because of running too many queries on Activity launch (for each row in a list view). Because I tried to reopen the same activity while the queries were being executed.

Fix : I ran only one query for the listview.

ReferenceURL : https://stackoverflow.com/questions/25132509/java-lang-runtimeexception-could-not-read-input-channel-file-descriptors-from-p

반응형