Open zxzxzxygithub opened 7 years ago
I asle meet this issue when run on Android 7.0 device.
Can confirm this, running 7.1.2.
Same error message:
--------- beginning of crash
E AndroidRuntime: FATAL EXCEPTION: cacheThread
E AndroidRuntime: Process: com.sigseg.android.worldmap, PID: 3535
E AndroidRuntime: java.lang.IllegalArgumentException: rectangle is outside the image
E AndroidRuntime: at android.graphics.BitmapRegionDecoder.decodeRegion(BitmapRegionDecoder.java:187)
E AndroidRuntime: at com.sigseg.android.view.InputStreamScene.fillCache(InputStreamScene.java:56)
E AndroidRuntime: at com.sigseg.android.view.Scene$CacheThread.run(Scene.java:525)
I Process : Sending signal. PID: 3535 SIG: 9
W ActivityManager: Force finishing activity com.sigseg.android.worldmap/com.sigseg.android.map.ImageViewerActivity
D GraphicsStats: Buffer count: 3
W InputDispatcher: channel 'c75e48e com.sigseg.android.worldmap/com.sigseg.android.map.ImageViewerActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
E InputDispatcher: channel 'c75e48e com.sigseg.android.worldmap/com.sigseg.android.map.ImageViewerActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
I WindowManager: WIN DEATH: Window{c75e48e u0 com.sigseg.android.worldmap/com.sigseg.android.map.ImageViewerActivity}
W InputDispatcher: Attempted to unregister already unregistered input channel 'c75e48e com.sigseg.android.worldmap/com.sigseg.android.map.ImageViewerActivity (server)'
W WindowManager: Force-removing child win Window{99040bc u0 SurfaceView - com.sigseg.android.worldmap/com.sigseg.android.map.ImageViewerActivity} from container Window{c75e48e u0 com.sigseg.android.worldmap/com.sigseg.android.map.ImageViewerActivity}
W WindowManager: Failed looking up window
W WindowManager: java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@da9c4af does not exist
W WindowManager: at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:9490)
W WindowManager: at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:9481)
W WindowManager: at com.android.server.wm.WindowState$DeathRecipient.binderDied(WindowState.java:1800)
W WindowManager: at android.os.BinderProxy.sendDeathNotice(Binder.java:688)
I WindowManager: WIN DEATH: null
W ActivityManager: Exception thrown during pause
W ActivityManager: android.os.DeadObjectException
W ActivityManager: at android.os.BinderProxy.transactNative(Native Method)
W ActivityManager: at android.os.BinderProxy.transact(Binder.java:615)
W ActivityManager: at android.app.ApplicationThreadProxy.schedulePauseActivity(ApplicationThreadNative.java:795)
W ActivityManager: at com.android.server.am.ActivityStack.startPausingLocked(ActivityStack.java:1148)
W ActivityManager: at com.android.server.am.ActivityStack.finishActivityLocked(ActivityStack.java:3586)
W ActivityManager: at com.android.server.am.ActivityStack.finishTopRunningActivityLocked(ActivityStack.java:3420)
W ActivityManager: at com.android.server.am.ActivityStackSupervisor.finishTopRunningActivityLocked(ActivityStackSupervisor.java:1865)
W ActivityManager: at com.android.server.am.AppErrors.handleAppCrashLocked(AppErrors.java:632)
W ActivityManager: at com.android.server.am.AppErrors.makeAppCrashingLocked(AppErrors.java:490)
W ActivityManager: at com.android.server.am.AppErrors.crashApplicationInner(AppErrors.java:357)
W ActivityManager: at com.android.server.am.AppErrors.crashApplication(AppErrors.java:308)
W ActivityManager: at com.android.server.am.ActivityManagerService.handleApplicationCrashInner(ActivityManagerService.java:13794)
W ActivityManager: at com.android.server.am.ActivityManagerService.handleApplicationCrash(ActivityManagerService.java:13776)
W ActivityManager: at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:1669)
W ActivityManager: at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3025)
W ActivityManager: at android.os.Binder.execTransact(Binder.java:565)
E lowmemorykiller: Error opening /proc/3535/oom_score_adj; errno=2
W ActivityManager: Failed setting process group of 3535 to 1
W System.err: java.lang.IllegalArgumentException: Given thread 3535 does not exist
W System.err: at android.os.Process.setThreadPriority(Native Method)
W System.err: at com.android.server.am.ActivityManagerService.applyOomAdjLocked(ActivityManagerService.java:20927)
W System.err: at com.android.server.am.ActivityManagerService.updateOomAdjLocked(ActivityManagerService.java:21462)
W System.err: at com.android.server.am.ActivityStack.resumeTopActivityInnerLocked(ActivityStack.java:2472)
W System.err: at com.android.server.am.ActivityStack.resumeTopActivityUncheckedLocked(ActivityStack.java:2137)
W System.err: at com.android.server.am.ActivityStackSupervisor.resumeFocusedStackTopActivityLocked(ActivityStackSupervisor.java:1843)
W System.err: at com.android.server.am.ActivityStackSupervisor.resumeFocusedStackTopActivityLocked(ActivityStackSupervisor.java:1833)
W System.err: at com.android.server.am.ActivityStack.startPausingLocked(ActivityStack.java:1203)
W System.err: at com.android.server.am.ActivityStack.finishActivityLocked(ActivityStack.java:3586)
W System.err: at com.android.server.am.ActivityStack.finishTopRunningActivityLocked(ActivityStack.java:3420)
W System.err: at com.android.server.am.ActivityStackSupervisor.finishTopRunningActivityLocked(ActivityStackSupervisor.java:1865)
W System.err: at com.android.server.am.AppErrors.handleAppCrashLocked(AppErrors.java:632)
W System.err: at com.android.server.am.AppErrors.makeAppCrashingLocked(AppErrors.java:490)
W System.err: at com.android.server.am.AppErrors.crashApplicationInner(AppErrors.java:357)
W System.err: at com.android.server.am.AppErrors.crashApplication(AppErrors.java:308)
W System.err: at com.android.server.am.ActivityManagerService.handleApplicationCrashInner(ActivityManagerService.java:13794)
W System.err: at com.android.server.am.ActivityManagerService.handleApplicationCrash(ActivityManagerService.java:13776)
W System.err: at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:1669)
W System.err: at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3025)
W System.err: at android.os.Binder.execTransact(Binder.java:565)
I WindowManager: Failed to capture screenshot of Token{519a5a9 ActivityRecord{fc92530 u0 com.sigseg.android.worldmap/com.sigseg.android.map.ImageViewerActivity t6 f}} appWin=Window{c63a6db u0 Starting com.sigseg.android.worldmap} drawState=2
W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:877 com.android.server.am.AppErrors.crashApplicationInner:374 com.android.server.am.AppErrors.crashApplication:308 com.android.server.am.ActivityManagerService.handleApplicationCrashInner:13794 com.android.server.am.ActivityManagerService.handleApplicationCrash:13776
Hi, looks like the BitmapDecoder.cpp of Android 7+ has problems when decoding big asset files. The way I fixed it is by converting the Asset InputStream into a byte array.
In InputStreamScene, instead of using BitmapFactory.decodeStream, I'm using BitmapFactory.decodeByteArray.
It works now!
when i use BitmapFactory.decodeByteArray in Android 7.1.2, it also crash, "rectangle is outside the image"!
@TyMarc how do you resolve this?
BitmapFactory.decodeByteArray(bytes, 0, bytes.length,tmpOptions);
public static byte[] toByteArray(InputStream input)
throws IOException
{
ByteArrayOutputStream output = new ByteArrayOutputStream();
copy(input, output);
return output.toByteArray();
}
public static int copy(InputStream input, OutputStream output)
throws IOException
{
long count = copyLarge(input, output);
if (count > 2147483647L) {
return -1;
}
return (int)count;
}
public static long copyLarge(InputStream input, OutputStream output)
throws IOException
{
byte[] buffer = new byte[4096];
long count = 0L;
int n = 0;
while (-1 != (n = input.read(buffer))) {
output.write(buffer, 0, n);
count += n;
}
return count;
}
I don't remember if that was it, but it was mostly fixed by this:
public void setInputStream(InputStream inputStream) throws IOException {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
byte[] buffer = new byte[8192];
int bytesRead;
ByteArrayOutputStream output = new ByteArrayOutputStream();
while ((bytesRead = inputStream.read(buffer)) != -1) {
output.write(buffer, 0, bytesRead);
}
byte[] file = output.toByteArray();
scene = new InputStreamScene(file);
} else {
scene = new InputStreamScene(inputStream);
}
}
@TyMarc Oh,yes, I try it success,thank u!
@cxmmxc In which file (where in the code) did you add @TyMarc's function?
log: java.lang.IllegalArgumentException: rectangle is outside the image at android.graphics.BitmapRegionDecoder.decodeRegion(BitmapRegionDecoder.java:187) at com.test.emptydemo.lib2.InputStreamScene.fillCache(InputStreamScene.java:63) at com.test.emptydemo.lib2.Scene$CacheThread.run(Scene.java:526)