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

Android Studio and Android application crashes with Filament Panic when trying several poly objects #866

Open MrCsabaToth opened 5 years ago

MrCsabaToth commented 5 years ago

I thought it gonna be easy to try to place some simple stop sign models onto an AR scene. I downloaded several stop sign models and a caution sign model from poly and all of them crashes Android Studio when I try to convert the obj (+ mtl + png) to sfa + sfb.

I see that Google (or JetBrains) receives a Crashlytics report about the crash, but I could gather some stderr info when I started the Studio from command line (and then you see the stderr):

N5utils17PreconditionPanicE
in filament::Material *filament::Material::Builder::build(filament::Engine &):86
reason: Material version mismatch. Expected 4 but received 1.
#0 /tmp/sceneform-filament-jni3535005164651508172/libfilament-jni.so(_ZN5utils6TPanicINS_17PreconditionPanicEE5panicEPKcS4_iS4_z+0x150) [0x7f87c18f1400]
#1 /tmp/sceneform-filament-jni3535005164651508172/libfilament-jni.so(_ZN8filament8Material7Builder5buildERNS_6EngineE+0x1ea) [0x7f87c1871fea]
#2 /tmp/sceneform-loader-jni3911963191015819184/libloader-jni.so(_ZN9sceneform6loader7details13BuildMaterialEPN8filament6EngineERKNS_12BufferAccessE+0x37) [0x7f87c15ea4b7]
#3 /tmp/sceneform-loader-jni3911963191015819184/libloader-jni.so(_ZN9sceneform6loader7details20CreateModelResourcesEPN8filament6EngineENSt3__u8functionIFNS_13OptionalErrorEN4absl11string_viewEPNS_12BufferAccessEEEEPKNS0_7schemas11LoadedModelEPNS_11TypedVectorIPNS2_12VertexBufferEEEPNSI_IPNS2_11IndexBufferEEEPNSI_IPNS2_7TextureEEEPNSI_IPNS2_8MaterialEEEPNSI_INS2_14TextureSamplerEEEPNS_12PairedVectorINS0_9ModelData14MaterialConfigENS_7TypedIdISW_tEEEEPNS1_16InflightCreationE+0xb0b) [0x7f87c15e26eb]
#4 /tmp/sceneform-loader-jni3911963191015819184/libloader-jni.so(_ZN9sceneform6loader7details7Creator11CreateModelEPN8filament6EngineEPNSt3__u10unique_ptrINS0_9ModelDataENS6_14default_deleteIS8_EEEE+0x13c) [0x7f87c15de33c]
#5 /tmp/sceneform-loader-jni3911963191015819184/libloader-jni.so(_ZN9sceneform6loader12LoaderInProc11CreateModelEPN8filament6EngineEPNSt3__u10unique_ptrINS0_9ModelDataENS5_14default_deleteIS7_EEEE+0x63) [0x7f87c15dd6c3]
#6 /tmp/sceneform-loader-jni3911963191015819184/libloader-jni.so(Java_com_google_ar_sceneform_assets_LoadedBundle_nCreateModelData+0x2f) [0x7f87c15d86ef]
terminating with uncaught exception of type utils::PreconditionPanic
Aborted

The sfa and sfb files are created though.

If I compile the file manually:

`$ ./build/sceneform_sdk/linux/converter -a -d --mat ./build/sceneform_sdk/default_materials/obj_material.sfm --outdir ./output/ ./sampledata/caution.obj
Warning: Imported asset was very large (2.6 x 4.3 x 2.0 m)
       : Setting scale to: 0.5000000 to compensate

There's no error message at all.

After that when I try either the Studio compiled version of sfb or the command line compiled one I get the same runtime error along with an application crash:

2019-09-14 14:23:44.203 22376-22376/? I/native: online_calibration_manager.cc:53 OnlineCalibrationManager: Could not open /data/user/0/com.valleydevfest.armap/cache/arcore-online-recalibration for reading.
2019-09-14 14:23:45.875 22376-22376/com.valleydevfest.armap I/native: cpu_feature_extractor.cc:60 Extracting FREAK descriptors.
2019-09-14 14:23:45.886 22376-22376/com.valleydevfest.armap I/native: device_provider.cc:1606 Identified device type: kOneplus6
2019-09-14 14:23:45.893 22376-22376/com.valleydevfest.armap I/native: session.cc:925 Entering Session::Resume.
2019-09-14 14:23:45.893 22376-22376/com.valleydevfest.armap I/native: android_camera.cc:675 Camera 0: State CLOSED: Reset cleanly got to CLOSED state.
2019-09-14 14:23:45.893 22376-22376/com.valleydevfest.armap I/native: pursuit_tracker.cc:1091 AugmentedRegion config changed, enabled:1, quad:true, downsample:true, global reacquisition:false, lite mode:false, adaptive frame delay:false
2019-09-14 14:23:45.894 22376-22459/com.valleydevfest.armap W/native: motion_analysis_calculator.cc:370 No input video header found. Downstream calculators expecting video headers are likely to fail.
2019-09-14 14:23:45.895 22376-22376/com.valleydevfest.armap I/CameraManagerGlobal: Connecting to camera service
2019-09-14 14:23:45.898 22376-22376/com.valleydevfest.armap W/CameraManagerGlobal: [soar.cts] ignore the status update of camera: 2
2019-09-14 14:23:45.898 22376-22376/com.valleydevfest.armap W/CameraManagerGlobal: [soar.cts] ignore the status update of camera: 3
2019-09-14 14:23:45.900 22376-22376/com.valleydevfest.armap I/native: session.cc:2396 Update Frame Delay to 3 frames.
2019-09-14 14:23:45.900 22376-22376/com.valleydevfest.armap I/native: android_sensors.cc:150 Starting thread.
2019-09-14 14:23:45.900 22376-22376/com.valleydevfest.armap I/native: cameras.cc:1118 Selected camera 0 stream 0 as feature extraction stream.
2019-09-14 14:23:45.900 22376-22465/com.valleydevfest.armap I/native: android_sensors.cc:28 Gyro min delay 5ms requesting 5ms
2019-09-14 14:23:45.912 22376-22465/com.valleydevfest.armap I/native: android_sensors.cc:28 Accel min delay 2.5ms requesting 5ms
2019-09-14 14:23:46.106 22376-22429/com.valleydevfest.armap I/native: cameras.cc:1269 Camera changed state from CLOSED to OPEN: Camera 0: State CLOSED: Camera device opened successfully.
2019-09-14 14:23:46.106 22376-22376/com.valleydevfest.armap I/native: session.cc:1055 Session::ResumeWithAnalytics returning OK.
2019-09-14 14:23:46.106 22376-22429/com.valleydevfest.armap I/native: cameras.cc:1269 Camera changed state from OPEN to CAPTURING: Started capture session.
2019-09-14 14:23:46.172 22376-22376/com.valleydevfest.armap E/native: session.cc:1784 Invalid ray produced by view data!
2019-09-14 14:23:46.183 22376-22393/com.valleydevfest.armap D/DecorView: onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@46be38b[MainActivity]
2019-09-14 14:23:46.185 22376-22486/com.valleydevfest.armap I/OpenGLRenderer: Initialized EGL, version 1.4
2019-09-14 14:23:46.185 22376-22486/com.valleydevfest.armap D/OpenGLRenderer: Swap behavior 2
2019-09-14 14:23:46.178 22376-22376/com.valleydevfest.armap W/RenderThread: type=1400 audit(0.0:1706264): avc: denied { read } for name="u:object_r:vendor_default_prop:s0" dev="tmpfs" ino=15908 scontext=u:r:untrusted_app:s0:c37,c257,c512,c768 tcontext=u:object_r:vendor_default_prop:s0 tclass=file permissive=0
2019-09-14 14:23:46.190 22376-22486/com.valleydevfest.armap E/libc: Access denied finding property "vendor.debug.egl.changepixelformat"
2019-09-14 14:23:46.238 22376-22486/com.valleydevfest.armap E/libc: Access denied finding property "vendor.debug.egl.swapinterval"
2019-09-14 14:23:46.228 22376-22376/com.valleydevfest.armap W/RenderThread: type=1400 audit(0.0:1706265): avc: denied { read } for name="u:object_r:vendor_default_prop:s0" dev="tmpfs" ino=15908 scontext=u:r:untrusted_app:s0:c37,c257,c512,c768 tcontext=u:object_r:vendor_default_prop:s0 tclass=file permissive=0
2019-09-14 14:23:46.267 22376-22486/com.valleydevfest.armap E/libc: Access denied finding property "vendor.debug.egl.changepixelformat"
2019-09-14 14:23:46.258 22376-22376/com.valleydevfest.armap W/RenderThread: type=1400 audit(0.0:1706266): avc: denied { read } for name="u:object_r:vendor_default_prop:s0" dev="tmpfs" ino=15908 scontext=u:r:untrusted_app:s0:c37,c257,c512,c768 tcontext=u:object_r:vendor_default_prop:s0 tclass=file permissive=0
2019-09-14 14:23:46.293 22376-22486/com.valleydevfest.armap E/libc: Access denied finding property "vendor.debug.egl.changepixelformat"
2019-09-14 14:23:46.311 22376-22486/com.valleydevfest.armap E/libc: Access denied finding property "vendor.debug.egl.swapinterval"
2019-09-14 14:23:46.315 22376-22376/com.valleydevfest.armap E/Filament: Panic
    in filament::Material *filament::Material::Builder::build(filament::Engine &):86
    reason: Material version mismatch. Expected 3 but received 1.
2019-09-14 14:23:46.315 22376-22376/com.valleydevfest.armap A/libc: Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 22376 (eydevfest.armap), pid 22376 (eydevfest.armap)
2019-09-14 14:23:46.328 22376-22466/com.valleydevfest.armap I/native: timebase_helpers.cc:168 Timebase offset intialized to 0
2019-09-14 14:23:46.330 22376-22459/com.valleydevfest.armap W/native: motion_analysis_calculator.cc:789 Requested image format in RegionFlowComputation does not match video stream format. Overriding.
2019-09-14 14:23:46.330 22376-22459/com.valleydevfest.armap I/native: region_flow_computation.cc:595 Instantiating and using NEON optimized non-OpenCV KLT.
2019-09-14 14:23:46.331 22376-22459/com.valleydevfest.armap I/native: motion_analysis_calculator.cc:618 Analyzed frame 1
2019-09-14 14:23:46.331 22376-22459/com.valleydevfest.armap W/native: parallel_invoker.h:300 Unsupported invoker mode selected on Android. Falling back to ThreadPool
2019-09-14 14:23:46.332 22376-22461/com.valleydevfest.armap W/native: tracking.cc:3303 Feature descriptors not exist
2019-09-14 14:23:46.332 22376-22461/com.valleydevfest.armap W/native: box_detector.cc:180 Detection skipped due to empty features or descriptors.
2019-09-14 14:23:46.348 22376-22443/com.valleydevfest.armap W/native: gyro_helper.cc:44 Gyro samples do not cover << [ 0 ; 1036182.20209369704 ] sec. Use identity R. Gyro samples cover [ 1036181.880060934 ; 1036182.24687504792 ] sec.
2019-09-14 14:23:46.349 22376-22444/com.valleydevfest.armap I/native: vio_initializer.cc:693 Not accepting frame as first BA keyframe.
2019-09-14 14:23:46.358 22376-22463/com.valleydevfest.armap W/native: tracking.cc:3303 Feature descriptors not exist
2019-09-14 14:23:46.358 22376-22463/com.valleydevfest.armap W/native: box_detector.cc:180 Detection skipped due to empty features or descriptors.
2019-09-14 14:23:46.398 22376-22461/com.valleydevfest.armap W/native: tracking.cc:3303 Feature descriptors not exist
2019-09-14 14:23:46.399 22376-22461/com.valleydevfest.armap W/native: box_detector.cc:180 Detection skipped due to empty features or descriptors.
2019-09-14 14:23:46.424 22376-22463/com.valleydevfest.armap W/native: tracking.cc:3303 Feature descriptors not exist
2019-09-14 14:23:46.424 22376-22463/com.valleydevfest.armap W/native: box_detector.cc:180 Detection skipped due to empty features or descriptors.
2019-09-14 14:23:46.444 22376-22444/com.valleydevfest.armap I/native: vio_initializer.cc:693 Not accepting frame as first BA keyframe.
2019-09-14 14:23:46.457 22376-22461/com.valleydevfest.armap W/native: tracking.cc:3303 Feature descriptors not exist
2019-09-14 14:23:46.457 22376-22461/com.valleydevfest.armap W/native: box_detector.cc:180 Detection skipped due to empty features or descriptors.
2019-09-14 14:23:46.494 22376-22460/com.valleydevfest.armap W/native: tracking.cc:3303 Feature descriptors not exist
2019-09-14 14:23:46.494 22376-22460/com.valleydevfest.armap W/native: box_detector.cc:180 Detection skipped due to empty features or descriptors.
2019-09-14 14:23:46.524 22376-22463/com.valleydevfest.armap W/native: tracking.cc:3303 Feature descriptors not exist
2019-09-14 14:23:46.524 22376-22463/com.valleydevfest.armap W/native: box_detector.cc:180 Detection skipped due to empty features or descriptors.
2019-09-14 14:23:46.552 22376-22444/com.valleydevfest.armap I/native: vio_initializer.cc:693 Not accepting frame as first BA keyframe.
2019-09-14 14:23:46.556 22376-22460/com.valleydevfest.armap W/native: tracking.cc:3303 Feature descriptors not exist
2019-09-14 14:23:46.556 22376-22460/com.valleydevfest.armap W/native: box_detector.cc:180 Detection skipped due to empty features or descriptors.
2019-09-14 14:23:46.589 22376-22461/com.valleydevfest.armap W/native: tracking.cc:3303 Feature descriptors not exist
2019-09-14 14:23:46.590 22376-22461/com.valleydevfest.armap W/native: box_detector.cc:180 Detection skipped due to empty features or descriptors.
2019-09-14 14:23:46.625 22376-22460/com.valleydevfest.armap W/native: tracking.cc:3303 Feature descriptors not exist
2019-09-14 14:23:46.625 22376-22460/com.valleydevfest.armap W/native: box_detector.cc:180 Detection skipped due to empty features or descriptors.
2019-09-14 14:23:46.656 22376-22461/com.valleydevfest.armap W/native: tracking.cc:3303 Feature descriptors not exist
2019-09-14 14:23:46.656 22376-22461/com.valleydevfest.armap W/native: box_detector.cc:180 Detection skipped due to empty features or descriptors.

I'm using Linux operating system

compileSdkVersion 28 minSdkVersion 24 targetSdkVersion 28 Android Studio 3.5 Google Sceneform Tools (Beta) 1.12.0

My application would be a simple concept but I'm kond of stuck because all models I tried so far does this. On the other hand the Sceneform Introduction codelab ran fine on my machine.

I'm giving more details below.

MrCsabaToth commented 5 years ago

Another example with a stop sign model, Studio crashes cold with the same Filament Precondition Panic (material expected 4 but received 1). Command line verbose compilation shows no error whatsoever:

$ ./build/sceneform_sdk/linux/converter -v -a -d --mat ./build/sceneform_sdk/default_materials/obj_material.sfm --outdir ./output/ ./sampledata/stopSign.obj
Info: Applied 1 material paths to 2 surfaces by duplicating the last path
Info: Generated SFA from ./sampledata/stopSign.obj
Info: Version: 0.540000.2
    : - Geometry Center (m): <0.000, 2.483, -0.056>
    : - Geometry Size (m)  : <1.848, 4.925, 0.150>
    : - Model 0/1: 70 Vertices
    :   - Attribute 0/3: Position (Vec3f)
    :   - Attribute 1/3: TexCoord (Vec2f)
    :   - Attribute 2/3: Orientation (Vec4f)
    :   - Material 0/2: 'lambert11SG' (32 Triangles)
    :   - Material 1/2: 'lambert12SG' (12 Triangles)
    : - Texture 0/1: 'stopSignTxt' (./sampledata/stopSignTxt.jpg, 58095 bytes)
    :   - Usage type: 'Color'
    :   - Mag filter: 'Linear', Min Filter: 'NearestMipmapLinear'
    :   - Wrap S: 'Repeat', Wrap T: 'Repeat'
    : - Material 0/2 (compiled index 0)
    :   - Parameter 0/5: 'baseColor' = "stopSignTxt"
    :   - Parameter 1/5: 'baseColorTint' = [1.000000, 1.000000, 1.000000, 1.000000]
    :   - Parameter 2/5: 'metallic' = 0.000000
    :   - Parameter 3/5: 'roughness' = 1.000000
    :   - Parameter 4/5: 'opacity' = null
    : - Material 1/2 (compiled index 1)
    :   - Parameter 0/5: 'baseColor' = null
    :   - Parameter 1/5: 'baseColorTint' = [0.240000, 0.060000, 0.010000, 1.000000]
    :   - Parameter 2/5: 'metallic' = 0.000000
    :   - Parameter 3/5: 'roughness' = 1.000000
    :   - Parameter 4/5: 'opacity' = null
    : - Compiled Material 0/2: 80237 bytes
    :   - sha1sum: 6ad1ac9da50771d8bace7364490226740b51b8a3
    : - Compiled Material 1/2: 79344 bytes
    :   - sha1sum: 93fd6a25cdea76764d62bd3082bba9dd1afc75eb
    : - Collision Shape:
    :   - Center: x=0.000000, y=2.462570, z=-0.000000
    :   - Size: x=1.847759, y=4.925140, z=0.150252
    : --- totals ---
    : - vertices: 2520 bytes
    : - indices: 132 bytes
    : - textures: 58095 bytes
    : - materials : 159581 bytes
Info: Wrote SFA (json) to ./output/stopSign.sfa (1331 bytes)
Info: Wrote SFB to ./output/stopSign.sfb (225368 bytes)

Now the app runtime crashes again with exactly the same Filament Panic as with the caution sign (expected material 3 but got 1). See LogCat of that crash

The stop sign object The caution sign object

I think the Android Studio Crash might not be because of the conversion but when it tries to open the sfb file and visualize it for me? When I completed some code labs the sfb file was never displayed graphically but just as binary sequence.

Screen recordings: Crashing Android Studio when trying to convert caution sign object AR Android app crash w caution sign crash and converting manually Crashing Android Studio when trying to convert stop sign object + manual conversion later AR Android app crash w caution sign crash and converting manually

tpsiaki commented 5 years ago

It looks like this is a mismatch in the version of the converter you are running and Sceneform 1.12 The 1.12 Android Studio plugin is only compatible with SFB files converted with Sceneform SDK 1.12 because of Filament material version changes.

The same is also true of Sceneform SDK 1.12 (i.e. your SFB files won't work with Sceneform 1.12 on Android if you are running an old version of the converter)

If you want to stay on the previous version of the converter, you should install the corresponding Sceneform Tools Android Studio plugin from the version download page.

MrCsabaToth commented 5 years ago

@tpsiaki I skimmed over the issues and I get that there can be binary format changes between sfb file versions. Even before that I erased the sfbs letting them regenerate, even so later I erased the sfas (along with removing the entries from the build.gradle so the sfas would also regenerate (and they are somewhat different actually)! However after the regeneration happens I thought there shouldn't be any crashes. During my manual regeneration attempts I use the converter executable which is populated by the plugin, so I guess the versions should match as well.

MrCsabaToth commented 5 years ago

@tpsiaki The Android Studio crash I'm sure is when it'd try to open and show me the sfb. I could easily get over that, but then the built Android app crashes as well, that's the real blocker problem. How can I clearly identify what kind of version mismatch I'm dealing with? All I can see is that both "before" and "after" sfas say version 0.54:2.