# Camera crash on Android 10

**URL:** <https://forums.fusetools.com/t/camera-crash-on-android-10/8091>\
**Category:** Bug Reports\
**Created:** [December 1, 2020, 10:24am UTC](https://forums.fusetools.com/t/camera-crash-on-android-10/8091 "2020-12-01T10:24:13Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShabbyAbby](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@ShabbyAbby](https://forums.fusetools.com/u/ShabbyAbby)\
**Post date:** [December 1, 2020, 10:24am UTC](https://forums.fusetools.com/t/camera-crash-on-android-10/8091/1 "2020-12-01T10:24:13Z")

</div>

Hello. I’m wondering if anyone has experienced some issues with Camera module on Android 10.

Simple Camera code:

```
function capturePhoto() {
	Camera.takePicture()
		.then(function (photo) {})
		.catch(function (error) {});
}

```

Information I’m getting from the debugger:

```
12-01 11:16:25.486 4058 4223 I InputDispatcher: Delivering touch to (8532): action: 0x0, f=0x0, d=0, 'fb5bd58', t=1
12-01 11:16:25.487 8532 8532 D ViewRootImpl@b37a917[APP]: ViewPostIme pointer 0
12-01 11:16:25.584 4058 4223 I InputDispatcher: Delivering touch to (8532): action: 0x1, f=0x0, d=0, 'fb5bd58', t=1
12-01 11:16:25.601 8532 8532 D ViewRootImpl@b37a917[APP]: ViewPostIme pointer 1
12-01 11:16:25.826 8532 8532 D ViewRootImpl@b37a917[APP]: MSG_WINDOW_FOCUS_CHANGED 0 1
12-01 11:16:25.828 8532 8532 D InputMethodManager: prepareNavigationBarInfo() DecorView@933ba[APP]
12-01 11:16:25.828 8532 8532 D InputMethodManager: getNavigationBarColor() -855310
12-01 11:16:25.832 3644 3644 I SurfaceFlinger: DEVICE | 0xf0f50440 | 0000 | RGBA_8888 | 0.0 0.0 1200.0 1920.0 | 0 0 1200 1920 | com.app.example/com.app.example.APP$_8532#0
12-01 11:16:25.852 4058 4077 D InputDispatcher: Focus left window (8532): fb5bd58 in display 0 0
12-01 11:16:25.964 3644 3644 I SurfaceFlinger: DEVICE | 0xf0f50440 | 0000 | RGBA_8888 | 0.0 1.0 1200.0 1920.0 | 0 0 1200 1920 | com.app.example/com.app.example.APP$_8532#0
12-01 11:16:25.983 3644 3644 I SurfaceFlinger: CLIENT | 0xf0f50440 | 0000 | RGBA_8888 | 0.0 3.0 1200.0 1920.0 | 0 0 1200 1918 | com.app.example/com.app.example.APP$_8532#0
12-01 11:16:26.271 8532 8532 D SurfaceView: onWindowVisibilityChanged(8) false android.view.SurfaceView{b762a7a V.E...... ........ 0,0-1200,1920} of ViewRootImpl@b37a917[APP]
12-01 11:16:26.272 8532 8532 D SurfaceView: surfaceDestroyed callback.size 1 #2 android.view.SurfaceView{b762a7a V.E...... ........ 0,0-1200,1920}
12-01 11:16:26.278 8532 8532 W libEGL : EGLNativeWindowType 0xbbb80808 disconnect failed
12-01 11:16:26.282 8532 8532 D SurfaceView: remove() android.view.SurfaceView{b762a7a V.E...... ........ 0,0-1200,1920} Surface(name=SurfaceView - com.app.example/com.app.example.APP@b762a7a@0)/@0xf6173d4
12-01 11:16:26.285 8532 13308 D OpenGLRenderer: makeCurrent EglSurface : 0xded1b2a0 -> 0x0
12-01 11:16:26.286 8532 13308 D OpenGLRenderer: destroyEglSurface : 0xded1b2a0
12-01 11:16:26.291 3644 6415 E BufferQueueProducer: [com.app.example/com.app.example.APP$_8532#0] disconnect: not connected (req=1)
12-01 11:16:26.291 8532 13308 W libEGL : EGLNativeWindowType 0xdcc56e08 disconnect failed
12-01 11:16:26.291 8532 13308 D OpenGLRenderer: ~ReliableSurface : 0xdcc56e00
12-01 11:16:26.301 4058 4695 V WindowManager: Relayout 8532: mAttrs={(0,0)(fillxfill) sim={adjust=resize} ty=BASE_APPLICATION fmt=TRANSPARENT wanim=0x1030305
12-01 11:16:26.309 8532 8532 D ViewRootImpl@b37a917[APP]: Relayout returned: old=(0,0,1200,1920) new=(0,0,1200,1920) req=(1200,1920)8 dur=14 res=0x5 s={false 0} ch=true
12-01 11:16:27.329 8532 8532 D InputTransport: Input channel destroyed: 'ClientS', fd=79
12-01 11:16:27.338 4058 4695 V InputMethodManagerService: Disabling: SessionState{uid 10216 pid 8532 method 3e751a4 session c9aaff1 channel ClientState{964017b uid=10216 pid=8532 displayId=0} (server)}
12-01 11:16:27.401 8532 8532 D ViewRootImpl@b37a917[APP]: stopped(true) old=false
12-01 11:16:27.417 8532 8532 D SurfaceView: windowStopped(true) false android.view.SurfaceView{b762a7a V.E...... ........ 0,0-1200,1920} of ViewRootImpl@b37a917[APP]
12-01 11:16:27.496 4058 4533 I WindowManager: Destroying surface Surface(name=com.app.example/com.app.example.APP$_8532)/@0xa957720 called by com.android.server.wm.WindowStateAnimator.destroySurface:1790 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:720 com.android.server.wm.WindowState.destroySurfaceUnchecked:3540 com.android.server.wm.WindowState.destroySurface:3514 com.android.server.wm.AppWindowToken.destroySurfaces:1234 com.android.server.wm.AppWindowToken.destroySurfaces:1215 com.android.server.wm.AppWindowToken.notifyAppStopped:1270 com.android.server.wm.ActivityRecord.activityStoppedLocked:2653
12-01 11:16:27.497 3644 3705 I Layer : id=2595 removeFromCurrentState com.app.example/com.app.example.APP$_8532#0 (65)
12-01 11:16:28.316 4058 5802 I ActivityManager: Process com.app.example (pid 8532) has died: prev LAST(390,93)
12-01 11:16:28.316 4058 5802 D ActivityManager_KPM: Killed Process Scenario:74 , App PID:8532 , App Name:com.app.example , App ADJ:700 , App AdjType:previous , Current CCH-ACT Count:1 , Proc State:16
12-01 11:16:28.316 3644 5309 I SurfaceFlinger: id=2595 Removed com.app.example/com.app.example.APP$_8532#0 (60)
12-01 11:16:28.318 3598 3598 I Zygote : Process 8532 exited due to signal 9 (Killed)
12-01 11:16:28.323 4058 4100 I libprocessgroup: Successfully killed process cgroup uid 10216 pid 8532 in 7ms
12-01 11:16:28.326 4058 4092 W ActivityManager: setHasOverlayUi called on unknown pid: 8532
12-01 11:16:28.330 3644 3644 I Layer : id=2595[1] Destroyed com.app.example/com.app.example.APP$_8532#0

```

Any idea what can be the issue here? Any possible fix?

---

<div class="post-metadata">

**Author:** ![Anagr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anagr/32/1037_2.png) [@Anagr](https://forums.fusetools.com/u/Anagr)\
**Post date:** [December 1, 2020, 10:30am UTC](https://forums.fusetools.com/t/camera-crash-on-android-10/8091/2 "2020-12-01T10:30:37Z")

</div>

Hi. When exactly it crashes? (When try to open Camera, after took a picture, etc …)

---

<div class="post-metadata">

**Author:** ![ShabbyAbby](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@ShabbyAbby](https://forums.fusetools.com/u/ShabbyAbby)\
**Post date:** [December 1, 2020, 10:33am UTC](https://forums.fusetools.com/t/camera-crash-on-android-10/8091/3 "2020-12-01T10:33:49Z")

</div>

Well the camera starts without any problem but application crashes in background.

I can still can take a picture (click “Ok” to accept the picture) but my application is restarted or switched off.

CameraRoll is working without any issues.

---

<div class="post-metadata">

**Author:** ![Anagr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anagr/32/1037_2.png) [@Anagr](https://forums.fusetools.com/u/Anagr)\
**Post date:** [December 1, 2020, 10:44am UTC](https://forums.fusetools.com/t/camera-crash-on-android-10/8091/4 "2020-12-01T10:44:24Z")

</div>

After some googling I found that the “Process 8532 exited due to signal 9 (Killed)” means the app was killed due to memory leaking. Possibly this module was not optimized for Android’s 10 SDK. Maybe it has different logic of image processing after capture

---

<div class="post-metadata">

**Author:** ![Anagr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anagr/32/1037_2.png) [@Anagr](https://forums.fusetools.com/u/Anagr)\
**Post date:** [December 1, 2020, 10:45am UTC](https://forums.fusetools.com/t/camera-crash-on-android-10/8091/5 "2020-12-01T10:45:50Z")

</div>

Did you tested your app on earlier versions of an Android?

---

<div class="post-metadata">

**Author:** ![Anagr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anagr/32/1037_2.png) [@Anagr](https://forums.fusetools.com/u/Anagr)\
**Post date:** [December 1, 2020, 10:47am UTC](https://forums.fusetools.com/t/camera-crash-on-android-10/8091/6 "2020-12-01T10:47:44Z")

</div>

Is this is the all your code in post or you cutted out some inner logic (inside .then()) ?

---

<div class="post-metadata">

**Author:** ![ShabbyAbby](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@ShabbyAbby](https://forums.fusetools.com/u/ShabbyAbby)\
**Post date:** [December 1, 2020, 10:55am UTC](https://forums.fusetools.com/t/camera-crash-on-android-10/8091/7 "2020-12-01T10:55:07Z")

</div>

I have some more code inside like `FileSystem.readBufferFromFileSync()` and `Base64.encodeBuffer()` but I have tested application only with code I have presented her and problem appears anyway.

Camera worked without any issues on early Android versions.

---

<div class="post-metadata">

**Author:** ![Anagr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anagr/32/1037_2.png) [@Anagr](https://forums.fusetools.com/u/Anagr)\
**Post date:** [December 1, 2020, 10:58am UTC](https://forums.fusetools.com/t/camera-crash-on-android-10/8091/8 "2020-12-01T10:58:32Z")

</div>

What version of Fuselibs do you use?

---

<div class="post-metadata">

**Author:** ![ShabbyAbby](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@ShabbyAbby](https://forums.fusetools.com/u/ShabbyAbby)\
**Post date:** [December 1, 2020, 11:04am UTC](https://forums.fusetools.com/t/camera-crash-on-android-10/8091/9 "2020-12-01T11:04:40Z")

</div>

I’m using 1.14.0 Fuselibs. Fuse-sdk updated to 1.14.1.

---

<div class="post-metadata">

**Author:** ![Anagr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anagr/32/1037_2.png) [@Anagr](https://forums.fusetools.com/u/Anagr)\
**Post date:** [December 1, 2020, 11:49am UTC](https://forums.fusetools.com/t/camera-crash-on-android-10/8091/10 "2020-12-01T11:49:37Z")

</div>

I looked at the source code of Camera Module 1.14.0, and yes, it has some code of support Android X way of working with files. Seems this have to be tested deeper

---

<div class="post-metadata">

**Author:** ![Hassan\_M](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/hassan_m/32/957_2.png) [@Hassan\_M](https://forums.fusetools.com/u/Hassan_M)\
**Post date:** [December 2, 2020, 5:19am UTC](https://forums.fusetools.com/t/camera-crash-on-android-10/8091/11 "2020-12-02T05:19:08Z")

</div>

It alot easier to debug if we can get some minimal reproducible code / test code that cause the error

---

<div class="post-metadata">

**Author:** ![ShabbyAbby](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@ShabbyAbby](https://forums.fusetools.com/u/ShabbyAbby)\
**Post date:** [December 2, 2020, 8:29am UTC](https://forums.fusetools.com/t/camera-crash-on-android-10/8091/12 "2020-12-02T08:29:01Z")

</div>

Ok, so here is my JS code I’m using. I have also got feedback that problem only happens on Android tablets like Samsung Galaxy Tab

```
let Observable = require('FuseJS/Observable');
let Camera = require('FuseJS/Camera');
let FileSystem = require('FuseJS/FileSystem');
let Base64 = require('FuseJS/Base64');
let Environment = require('FuseJS/Environment');
let CameraRoll = require('FuseJS/CameraRoll');
let ImageTools = require('FuseJS/ImageTools');

let showLoading = Observable(false);
let images = Observable();
    
function capturePhoto() {
    	showLoading.value = true;
    	Camera.takePicture()
    		.then(function (photo) {
    			CameraRoll.publishImage(photo).then(() => {
    				const aspectMode = (Environment.android) ? ImageTools.KEEP_ASPECT : ImageTools.IGNORE_ASPECT;
    				
    				let options = {
    					mode: aspectMode,
    					desiredWidth: 480,
    					desiredHeight: 640
    				};

    				ImageTools.resize(photo, options).then((newImage) => {
    					let arrayBuff = FileSystem.readBufferFromFileSync(
    						newImage.path
    					);
    					let b64data = Base64.encodeBuffer(arrayBuff);

    					images.add({
    						path: newImage.path,
    						name: photo.name,
    						img: b64data,
    						desc: Observable('')
    					});
    				}).then(() => {
    					showLoading.value = false;
    				})
    			})
    		})
    		.catch(function (error) {
    			showLoading.value = false;
    			console.log('Failed to capture photo: ' + error);
    		});
    }
```

---

<div class="post-metadata">

**Author:** ![Hassan\_M](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/hassan_m/32/957_2.png) [@Hassan\_M](https://forums.fusetools.com/u/Hassan_M)\
**Post date:** [December 3, 2020, 2:13am UTC](https://forums.fusetools.com/t/camera-crash-on-android-10/8091/13 "2020-12-03T02:13:06Z")

</div>

It might be something to do with the out of memory problem, just like in the discussion of this [thread](https://forums.fusetools.com/t/exiting-app-after-take-picture/5369).

Try to call `takePicture` with the size of the parameters like: `Camera.TakePicture(640,480)` to limit the size of the picture is taken.

---

<div class="post-metadata">

**Author:** ![ShabbyAbby](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@ShabbyAbby](https://forums.fusetools.com/u/ShabbyAbby)\
**Post date:** [December 3, 2020, 1:37pm UTC](https://forums.fusetools.com/t/camera-crash-on-android-10/8091/14 "2020-12-03T13:37:48Z")

</div>

I tried your solution but it didn’t work.

I did some testing and it look like the camera is killing the application when there are a lot of observables showing on page. It looks like it works without any problems on empty pages.

I tried to do some profiling for memory leaks with Android Studio but the app crashes already from the start.

---

<div class="post-metadata">

**Author:** ![ShabbyAbby](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@ShabbyAbby](https://forums.fusetools.com/u/ShabbyAbby)\
**Post date:** [January 11, 2021, 11:24am UTC](https://forums.fusetools.com/t/camera-crash-on-android-10/8091/15 "2021-01-11T11:24:08Z")

</div>

It looks like the problem appears only for Samsung devices.
