google-ar / sceneform-android-sdk

Sceneform SDK for Android
https://developers.google.com/sceneform/develop/
Apache License 2.0
1.23k stars 604 forks source link

ViewRenderable with multiple ImageView added to scene turns into low frame rate and crash - AMEDIA_IMGREADER_NO_BUFFER_AVAILABLE #940

Open luislukas opened 4 years ago

luislukas commented 4 years ago

I'm inflating a basic layout with an ImageView using the ViewRenderable.builder().setView(...) approach. My use case needs to fetch the images from a server so I'm using Glide for this purpose. After that, I can successfully place the view in a Node and see it in the SceneView. The problem comes when doing the same with multiple views - I always end up with low frame rate and eventually the following crash:

12-04 12:19:17.592 24211 24586 E native  : camera_image_stream.cc:230 Camera Image Stream failed to dequeue Image from ImageReader. status=ImageReaderStatusErrorSpaceClass::AMEDIA_IMGREADER_NO_BUFFER_AVAILABLE: AImageReader_acquireLatestImage acquired_image_count=10
12-04 12:19:17.596 25016 25016 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
12-04 12:19:17.596 25016 25016 F DEBUG   : Build fingerprint: 'google/sailfish/sailfish:10/QP1A.191005.007.A1/5908163:user/release-keys'
12-04 12:19:17.596 25016 25016 F DEBUG   : Revision: '0'
12-04 12:19:17.596 25016 25016 F DEBUG   : ABI: 'arm64'
12-04 12:19:17.597 25016 25016 F DEBUG   : Timestamp: 2019-12-04 12:19:17+0000
12-04 12:19:17.597 25016 25016 F DEBUG   : pid: 24211, tid: 24211, name: iday.package  >>> my.custom.package <<<
12-04 12:19:17.597 25016 25016 F DEBUG   : uid: 10433
12-04 12:19:17.597 25016 25016 F DEBUG   : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x7100000061
12-04 12:19:17.598 25016 25016 F DEBUG   :     x0  0000006fc717b880  x1  0000007ff3023b20  x2  0000000000000000  x3  00000070c28e1a98
12-04 12:19:17.598 25016 25016 F DEBUG   :     x4  0000007ff3023a38  x5  000000000000004a  x6  4055404906ff5140  x7  7f7f7f7f7f7f7f7f
12-04 12:19:17.598 25016 25016 F DEBUG   :     x8  0000007100000000  x9  00000000a209c4c0  x10 0000000010000000  x11 0000000000000000
12-04 12:19:17.598 25016 25016 F DEBUG   :     x12 0000000000000055  x13 fffffffffffff800  x14 0000000000000001  x15 00000070c28ef1b5
12-04 12:19:17.598 25016 25016 F DEBUG   :     x16 00000071467b2498  x17 0000007145596588  x18 0000007147fe2000  x19 0000000000014306
12-04 12:19:17.598 25016 25016 F DEBUG   :     x20 000000705de95400  x21 0000007ff3023bc8  x22 00000000fa209c4c  x23 0000000000000000
12-04 12:19:17.598 25016 25016 F DEBUG   :     x24 0000007041097900  x25 0000000012e405b0  x26 00000000139193e8  x27 0000000013b56ba8
12-04 12:19:17.598 25016 25016 F DEBUG   :     x28 0000007ff3023c60  x29 0000007ff3023c60
12-04 12:19:17.598 25016 25016 F DEBUG   :     sp  0000007ff3023b90  lr  00000070418f46fc  pc  00000070418f470c
12-04 12:19:17.598 25016 25016 F DEBUG   : 
12-04 12:19:17.598 25016 25016 F DEBUG   : backtrace:
12-04 12:19:17.599 25016 25016 F DEBUG   :       #00 pc 000000000005d70c  /data/app/my.package.here-RgVhFhOOJ9Ym6OoemSs8ag==/lib/arm64/libfilament-jni.so (BuildId: b4887cba4bb344074075aa1dfaaf1841921c5ffc)
12-04 12:19:17.715 24211 24542 I native  : performance_monitor.cc:115 Event: FeatureExtraction is taking too long, it took 110.083ms

I'm using the ArFragment approach and SceneForm version 1.13.0 in case it helps. I've tested with different image sizes and the bigger the image the sooner the crash happens. Also if the images are less heavy - few hundred kb, then I need to add more for the crash to happen (probably around 10). I found the following issue, now closed, that I think could be related (although seems that we have different use case.) https://github.com/google-ar/sceneform-android-sdk/issues/181 Basically my question then, would be, are we meant to just use textures etc and not images (png, jpg etc) ?

luislukas commented 4 years ago

The issue seems to be solved when setting this property rather than using the default priority. I

sceneView.cameraStreamRenderPriority = Renderable.RENDER_PRIORITY_FIRST

I guess this can be closed. It'd be good to know does the property do. Is it just allocating more resources to render images/nodes etc? UPDATE: I think I was too optimistic, it happened again as soon as I made the ImageView 100x100 pixel size. If I keep them around 50x50 it can handle more.