Consumer closed input channel or an error occurred. events=0x8

將代碼移植到android的過程中出現了一個問題:

04-18 15:30:54.854: E/InputDispatcher(1568): channel '407d93b0 com.mobiap.casino/com.mobiap.casino.android_casino (server)' ~ Consumer closed input channel or an error occurred. events=0x8
04-18 15:30:54.854: E/InputDispatcher(1568): channel '407d93b0 com.mobiap.casino/com.mobiap.casino.android_casino (server)' ~ Channel is unrecoverably broken and will be disposed!

我用的是魅族M9,系統爲2.3的,coco2d-x版本爲2.0.1的

經過baidu+google後,搜索到了以下幾種解決方案:

1.由於橫豎屏切換導致出現該錯誤。(找到最多的一種解決方案)

具體修正方法爲:在manifest.xml中設置android:launchMode="singleTask" android:screenOrientation="portrait" android:configChanges="orientation|keyboardHidden"

結果:果然不行!在進行過以上設置後發現,該咋樣還是咋樣,查找程序代碼發現根本就不是進行了橫豎屏的切換,該方法放棄,繼續搜索。

2.將sd卡中的緩存刪掉。

操作:果斷刪之,連程序都給卸了。

結果:果然還是不行,總不能將系統給重裝吧!

3.網上說是2.3系統的bug

操作:這。。。

結果:繼續找吧!

4.找到cocos2d-x官網論壇中的一個老外的帖子,其出現的結果跟我一模一樣啊,內容如下:

WIN DEATH: but why?

發帖數

49

 Ron Mobi  5 個月 之前添加

Hi, two days i try to avoid this error :( After this my app closes.

04-18 15:30:54.404: I/DEBUG: * *
04-18 15:30:54.404: I/DEBUG: Build fingerprint: 'lge/thunderg/thunderg:2.3.3/GRI40/LG-P500-V20c.19C1E59AC2:user/ota-rel-keys,release-keys'
04-18 15:30:54.404: I/DEBUG: >>> com.mobiap.casino <<<
04-18 15:30:54.404: I/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
04-18 15:30:54.404: I/DEBUG: r0 ffffffff r1 73746000 r2 00000004 r3 ffff0ff0
04-18 15:30:54.414: I/DEBUG: r4 00000000 r5 73746000 r6 afd46470 r7 00000000
04-18 15:30:54.414: I/DEBUG: r8 aca4a965 r9 00098450 10 00100000 fp 00000001
04-18 15:30:54.414: I/DEBUG: ip afd24579 sp 100ffe28 lr afd24571 pc aca652c2 cpsr 80000030
04-18 15:30:54.414: I/DEBUG: d0 400000003eaaaaab d1 3ff0000041f00000
04-18 15:30:54.424: I/DEBUG: d2 bfd3441350baf6de d3 c1493000c1323800
04-18 15:30:54.424: I/DEBUG: d4 4900000040f7b000 d5 000000000007bd80
04-18 15:30:54.424: I/DEBUG: d6 4515a00000000800 d7 40800000c48ee000
04-18 15:30:54.424: I/DEBUG: d8 0000000000000000 d9 0000000000000000
04-18 15:30:54.424: I/DEBUG: d10 0000000000000000 d11 0000000000000000
04-18 15:30:54.424: I/DEBUG: d12 0000000000000000 d13 0000000000000000
04-18 15:30:54.424: I/DEBUG: d14 0000000000000000 d15 0000000000000000
04-18 15:30:54.424: I/DEBUG: scr 80000012
04-18 15:30:54.534: I/DEBUG: #00 pc 000652c2 /system/lib/libdvm.so
04-18 15:30:54.534: I/DEBUG: #01 lr afd24571 /system/lib/libc.so
04-18 15:30:54.534: I/DEBUG: code around pc:
04-18 15:30:54.534: I/DEBUG: aca652a0 000267ab 4b09b570 0b0d1c14 0b1018c2 
04-18 15:30:54.534: I/DEBUG: aca652b0 032d0300 d20742a8 1c291a2d f7ac2204 
04-18 15:30:54.534: I/DEBUG: aca652c0 6820eaf8 60211941 46c0bd70 00000fff 
04-18 15:30:54.534: I/DEBUG: aca652d0 4b10b5f8 447b1c01 6d066818 d0162900 
04-18 15:30:54.534: I/DEBUG: aca652e0 23001c02 e00b251c 42a16ad4 1c2cd306 
04-18 15:30:54.544: I/DEBUG: code around lr:
04-18 15:30:54.544: I/DEBUG: afd24550 ffffff8c 00028e2e 0000076c 2301b510 
04-18 15:30:54.544: I/DEBUG: afd24560 fdd0f7ff 46c0bd10 1c04b510 fd36f7ed 
04-18 15:30:54.544: I/DEBUG: afd24570 20016004 bd104240 1c03b510 db0233ff 
04-18 15:30:54.544: I/DEBUG: afd24580 f7ff4240 bd10fff1 4d1bb5f0 4f1c4b1b 
04-18 15:30:54.544: I/DEBUG: afd24590 58ea447d 880359ec 88278811 1c0eb087 
04-18 15:30:54.544: I/DEBUG: stack:
04-18 15:30:54.544: I/DEBUG: 100ffde8 00000000 
04-18 15:30:54.544: I/DEBUG: 100ffdec 00000000 
04-18 15:30:54.544: I/DEBUG: 100ffdf0 00000000 
04-18 15:30:54.544: I/DEBUG: 100ffdf4 00000000 
04-18 15:30:54.544: I/DEBUG: 100ffdf8 00000000 
04-18 15:30:54.544: I/DEBUG: 100ffdfc 00000000 
04-18 15:30:54.544: I/DEBUG: 100ffe00 00000000 
04-18 15:30:54.544: I/DEBUG: 100ffe04 00000000 
04-18 15:30:54.544: I/DEBUG: 100ffe08 00000000 
04-18 15:30:54.544: I/DEBUG: 100ffe0c 00000000 
04-18 15:30:54.544: I/DEBUG: 100ffe10 00000000 
04-18 15:30:54.544: I/DEBUG: 100ffe14 00000000 
04-18 15:30:54.544: I/DEBUG: 100ffe18 00000000 
04-18 15:30:54.554: I/DEBUG: 100ffe1c afd24587 /system/lib/libc.so
04-18 15:30:54.554: I/DEBUG: 100ffe20 df002777 
04-18 15:30:54.554: I/DEBUG: 100ffe24 e3a070ad 
04-18 15:30:54.554: I/DEBUG: #00 100ffe28 00000000 
04-18 15:30:54.554: I/DEBUG: 100ffe2c 00000000 
04-18 15:30:54.554: I/DEBUG: 100ffe30 00000000 
04-18 15:30:54.554: I/DEBUG: 100ffe34 00000000 
04-18 15:30:54.554: I/DEBUG: 100ffe38 00000000 
04-18 15:30:54.554: I/DEBUG: 100ffe3c 00000000 
04-18 15:30:54.554: I/DEBUG: 100ffe40 00000000 
04-18 15:30:54.554: I/DEBUG: 100ffe44 00000000 
04-18 15:30:54.554: I/DEBUG: 100ffe48 00000000 
04-18 15:30:54.554: I/DEBUG: 100ffe4c 00000000 
04-18 15:30:54.554: I/DEBUG: 100ffe50 00000000 
04-18 15:30:54.554: I/DEBUG: 100ffe54 00000000 
04-18 15:30:54.554: I/DEBUG: 100ffe58 00000000 
04-18 15:30:54.554: I/DEBUG: 100ffe5c 00000000 
04-18 15:30:54.554: I/DEBUG: 100ffe60 00000000 
04-18 15:30:54.554: I/DEBUG: 100ffe64 00000000 
04-18 15:30:54.554: I/DEBUG: 100ffe68 00000000 
04-18 15:30:54.554: I/DEBUG: 100ffe6c 00000000 
04-18 15:30:54.674: I/DEBUG: debuggerd committing suicide to free the zombie!
04-18 15:30:54.674: I/BootReceiver(1568): Copying /data/tombstones/tombstone_02 to DropBox (SYSTEM_TOMBSTONE)
04-18 15:30:54.704: I/DEBUG: debuggerd: Jun 27 2011 23:27:49
04-18 15:30:54.754: D/StatusBarPolicy(1649): [BRIGHTHY] 0. mDataNetType: 2
04-18 15:30:54.754: D/StatusBarPolicy(1649): [BRIGHTHY] curNetwork=25020 curHPLMN=25020
04-18 15:30:54.834: I/ActivityManager(1568): Process com.mobiap.casino (pid 1051) has died.
04-18 15:30:54.854: E/InputDispatcher(1568): channel '407d93b0 com.mobiap.casino/com.mobiap.casino.android_casino (server)' ~ Consumer closed input channel or an error occurred. events=0x8
04-18 15:30:54.854: E/InputDispatcher(1568): channel '407d93b0 com.mobiap.casino/com.mobiap.casino.android_casino (server)' ~ Channel is unrecoverably broken and will be disposed!
04-18 15:30:54.854: I/WindowManager(1568): WIN DEATH: Window{407d93b0 com.mobiap.casino/com.mobiap.casino.android_casino paused=false}
04-18 15:30:54.904: I/WindowManager(1568): WIN DEATH: Window{407e4130 SurfaceView paused=false}
04-18 15:30:54.924: I/WindowManager(1568): Setting rotation to 0, animFlags=1
04-18 15:30:54.924: I/ActivityManager(1568): Config changed: { scale=1.0 imsi=250/20 loc=ru_RU touch=3 keys=1/1/2 nav=1/1 orien=1 layout=18 uiMode=17 seq=606}

It happens on all game screens in random time, i can't understand why. What the reason of this error, who knows ?

F Es

RE: WIN DEATH: but why?

發帖數

29

 

 F Es  5 個月 之前添加

I am also getting a couple of this random crashes from time to time.

Ron Mobi

RE: WIN DEATH: but why?

發帖數

49

 

 Ron Mobi  5 個月 之前添加

And how did you resolve this problem?

Milda Genius

RE: WIN DEATH: but why?

發帖數

105

 

 Milda Genius  5 個月 之前添加

Me too. I dont have solution yet.

Ron Mobi

RE: WIN DEATH: but why?

發帖數

49

 

 Ron Mobi  5 個月 之前添加

What is the reason of this error ? Graphics? Version of sdk and ndk ? Developers of cocos2d-x , please, help us ! :) Our customer complains ! :(

Milda Genius,
What version of sdk and ndk does you use?
I use cocos2d-x 0.10.0 and ndk by crystax nr7

Ron Mobi

RE: WIN DEATH: but why?

發帖數

49

 

 Ron Mobi  5 個月 之前添加

I downloaded sdk ver. 12, and... My App shut at the beginning ! With WIN DEATH again :(

Ron Mobi

RE: WIN DEATH: but why?

發帖數

49

 

 Ron Mobi  5 個月 之前添加

I checked game under all versions of cocos2d-x. I got to run the program. But I always get WIN DEATH: in random time.
So idea, that this mistake depends on versions of sdk and ndk, can be ignored.

Ron Mobi

RE: WIN DEATH: but why?

發帖數

49

 

 Ron Mobi  5 個月 之前添加

Could it be call UserDefaults?

Minggo Zhang

RE: WIN DEATH: but why?

發帖數

1409

 

 Minggo Zhang  5 個月 之前添加

Why not use official ndk?

Ron Mobi

RE: WIN DEATH: but why?

發帖數

49

 

 Ron Mobi  5 個月 之前添加

Dear Minggo, I downloaded official ndk r7. Same problem. Maybe try ndk r6 ? But where i can get it?

Ron Mobi

RE: WIN DEATH: but why?

發帖數

49

 

 Ron Mobi  5 個月 之前添加

I downloaded ndk 6, but in cygwin i get:

make: Entering directory `/cygdrive/d/cocos2d-1.0.1-x-0.12.0/casinoshka/android'
Gdbserver : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup : libs/armeabi/gdb.setup
Install : libcocosdenshion.so => libs/armeabi/libcocosdenshion.so
SharedLibrary : libgame.so
D:/android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld.exe: cannot find -lGLESv1_CM
collect2: ld returned 1 exit status
/cygdrive/d/android-ndk-r6/build/core/build-binary.mk:280: recipe for target `/cygdrive/d/cocos2d-1.0.1-x-0.12.0/casinoshka/android/obj/local/armeabi/libgame.so' failed
make: *** [/cygdrive/d/cocos2d-1.0.1-x-0.12.0/casinoshka/android/obj/local/armeabi/libgame.so] Error 1
make: Leaving directory `/cygdrive/d/cocos2d-1.0.1-x-0.12.0/casinoshka/android'

Minggo Zhang

RE: WIN DEATH: but why?

發帖數

1409

 

 Minggo Zhang  5 個月 之前添加

May be these documents can help 
Build project with ndk-r7
Some cautions of Android 4.0

Ron Mobi

RE: WIN DEATH: but why?

發帖數

49

 

 Ron Mobi  5 個月 之前添加

I tried it. Same result. Please, say, in what cause of problem ? Big size of graphics, using of UserDefaults, anything else ?

Minggo Zhang

RE: WIN DEATH: but why?

發帖數

1409

 

 Minggo Zhang  5 個月 之前添加

I haven't meet the problem.
If you can provide a demo to reproduce it. It may be helpful for us to resolve it.

Ron Mobi

RE: WIN DEATH: but why?

發帖數

49

 

 Ron Mobi  5 個月 之前添加

Ok, there is last version
http://depositfiles.com/files/7g4m1oqmq
Sorry for erotic content, requirement of customer :) Our game not for market.

Ron Mobi

RE: WIN DEATH: but why?

發帖數

49

 

 Ron Mobi  5 個月 之前添加

Anybody tryed? I still can not resolve problem :(

Andre Rudlaff

RE: WIN DEATH: but why?

發帖數

15

 

 Andre Rudlaff  5 個月 之前添加

I have not tried your code.

Are you building your naitve code for arm and armv7a?
There was a bug in ndk7b which caused crashes on armv7a devices without the NEON instruction set (like Tegra 2 devices)
Maybe it helps if you update to ndk7c.

If you are not sure, simply look at the libs directory of your project if it contains both the arm and armv7 folder you are building for armv7a.

If that doesn't help, is there any output before the crash? like a jni warning or something like that?

Can you reproduce the error when building for Linux/Windows/iOS.
In that case it may be helpful to attach a debugger or do some valgrind checking (Linux only)

Ron Mobi

RE: WIN DEATH: but why?

發帖數

49

 

 Ron Mobi  4 個月 之前添加

I used only 1 scene. Without scene's pushes and pops. I had 7 Scenes. Now I put Layers on 1 Scene. Please, tell, why with may scenes we have memory leaks?

操作:看~!當時看到這篇帖子,心情那個激動啊,從第一個英文到最後一個英文字母看完後。

結果:發現到最後也沒給個具體解決方案。心情當時那個涼啊。

沒辦法只好找該作者本人,發個email,純英文的,內容大概是看他搞定沒,搞定了給咱個具體解決方案啊什麼的,呵呵,上午發過去,下午人家就回過來了,不錯,這個老外真心不錯,不坑爹啊!接下來,我把他發的內容公佈下:

My mistake was in code, for example:


//create new csene
 CCScene *levelsScene = new CCScene( );
 levelsScene -> autorelease( );


 //create new layer for game
 CCLayer *levels = new Levels( );
 levels -> autorelease( );
 levels -> setPosition( ccp( 0, 0 ) );


 //add our layer to scene
 levelsScene -> addChild( levels, 0 );


 //push new scene
 CCDirector::sharedDirector( ) -> pushScene( CCTransitionFade::create( 0.5f, levelsScene, ccBLACK ) );


In that case I didn't use autorelease( ) and got memory leaks! So now I use it and all is ok.


And as I understand - WIN DEATH: is not mistake. So the app close itself. Try to quit and in eclipse logcat you will see win death =)

 

Hope, that it will help.

 

原來是他的一個scene沒autorelease纔出現了該錯誤的。接下來我按照他給的方案檢查下代碼,並將每個scene都加了autorelease了,運行下,發現,結果:還是不行!難道老外也坑爹?不行,再試試,運行了3遍後,果斷放棄。

坑爹啊,馬上一個下午都快沒了,得趕緊找個解決方案出來啊。

得!還是靜下心來找具體的出錯原因吧,根據老外的思路,他應該是在運行的過程中出現了錯誤提示,但是在編譯的過程中沒有出現,也就是說這個錯誤是由於錯誤的運行結果導致的。根據這個思路,繼續查找代碼,打log查看每個變量的值,終於,發現了,是的,真的發現了!

具體原因:由於在加載程序時需要解析xml配置文件,而在win32下面解析xml文件的話只需要xmlReadFile,找到xml的路徑加載就可以了,但是在android中繼續使用xmlReadFile的話是不行的,需要xmlReadMemory,而之前讀取xml的方式也需要改變,改爲:(代碼僅供參考,只提供具體思路)

  CCFileUtils* fileUtils;

const char* path = fileUtils->fullPathFromRelativePath(yourfilename);    

unsigned long size ;

char* data=(char*)fileUtils->getFileData (path, "rt", &size )

doc = xmlReadMemory(data, size, NULL, "UTF-8", XML_PARSE_RECOVER);

//接下來就是解析xml的操作了。。。你想幹嘛就幹嘛吧

。。。。。。。。。。。。

總結:遇到問題不能太急,這樣反而起到反作用,需要冷靜下來,觀察到底哪裏出了錯,這樣才能找到最終的原因。該問題主要原因還是出在對libxml的瞭解不清楚,對不同平臺下的支持不同,從這個問題中值得反思啊!!!

最後感謝以下文章的大力支持!

http://blog.csdn.net/yuanhong2910/article/details/7030289

http://www.cocos2d-x.org/boards/6/topics/10378

 

 

 

完!

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章