google / filament

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2
https://google.github.io/filament/
Apache License 2.0
17.53k stars 1.85k forks source link

Crash on iPad Air 2 #7963

Closed xiamingwei-sudo closed 1 week ago

xiamingwei-sudo commented 1 month ago

⚠️ Issues not using this template will be systematically closed.

Describe the bug crash on ipad air2, and happens always. Is there anyone have solutions? thanks

Logs

          Crashed: FEngine::loop
0  libsystem_kernel.dylib         0x6bbc __pthread_kill + 8
1  libsystem_pthread.dylib        0xd844 pthread_kill + 208
2  libsystem_c.dylib              0x1f6ac abort + 124
3  SoundCore                      0x3e59964 utils::PostconditionPanic::PostconditionPanic(char const*, char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) + 136
4  SoundCore                      0x3d528bc filament::backend::DepthStateCreator::operator()(id<MTLDevice>, filament::backend::DepthStencilState const&) + 4361676988
5  SoundCore                      0x3d3c60c filament::backend::StateCache<filament::backend::MetalPipelineState, id<MTLRenderPipelineState> __strong, filament::backend::PipelineStateCreator, utils::hash::MurmurHashFn<filament::backend::MetalPipelineState>>::getOrCreateState(filament::backend::MetalPipelineState const&) + 4361586188
6  SoundCore                      0x3d461b4 filament::backend::ConcreteDispatcher<filament::backend::MetalDriver>::draw(filament::backend::Driver&, filament::backend::CommandBase*, long*) + 4361626036
7  SoundCore                      0x3d22708 std::__1::__function::__func<filament::backend::CommandStream::execute(void*)::$_0, std::__1::allocator<filament::backend::CommandStream::execute(void*)::$_0>, void ()>::operator()() + 4361479944
8  SoundCore                      0x3d476a4 filament::backend::MetalDriver::execute(std::__1::function<void ()> const&) + 4361631396
9  SoundCore                      0x3d22470 filament::backend::CommandStream::execute(void*) + 4361479280
10 SoundCore                      0x3ded048 filament::FEngine::loop() + 166240

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

bejado commented 1 month ago

There should be a postcondition reason printed in the logs. Can you check again and see if there's additional information about the crash?

xiamingwei-sudo commented 1 month ago

thans you for response When I use Xcode debug, I get the following crash message

my device is iPad mini 3 os: 12.5.5 Backend: Metal

this is my code, and crashed on rendererManager.setMaterialInstanceAt(renderer, index, newMaterialInstance);

- (void)updateMaterialInstance:(MaterialInstance *)materialInstance withName:(NSString *)name rgba:(math::float4)rgba prNamePrefix:(NSString *)prNamePrefix material:(filament::Material *)material renderer:(RenderableManager::Instance)renderer index:(int)index {
    if (![name hasPrefix:prNamePrefix]) {
        return;
    }
    NSLog(@"updateFilamatWithBuffer prNamePrefix:%@, name: %@", prNamePrefix, name);
    auto& rendererManager = _engine->getRenderableManager();
    auto newMaterialInstance = material->createInstance();
    rendererManager.setMaterialInstanceAt(renderer, index, newMaterialInstance);
    [self setMaterialParameters:newMaterialInstance withRGBA:rgba];
}

crash:

2024-07-10 13:11:27.489492+0800 SoundCore[402:15649] [BLEPeripheral:137-notifyCharacteristicChange(_:)]🐛 notifyCharacteristicChange: <CBCharacteristic: 0x128dbe8f0, UUID = 8888, properties = 0x92, value = <09ff0000 010e070a 0028>, notifying = YES>, value: Optional(10 bytes)
Warning: sample comparison not supported by this GPU
2024-07-10 13:11:30.547020+0800 SoundCore[402:15649] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C18.1:2][0x13bf3d0a0] get output frames failed, state 8196
2024-07-10 13:11:30.548916+0800 SoundCore[402:15649] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C18.1:2][0x13bf3d0a0] get output frames failed, state 8196
2024-07-10 13:11:30.551812+0800 SoundCore[402:15649] TIC Read Status [18:0x0]: 1:57
2024-07-10 13:11:30.552141+0800 SoundCore[402:15649] TIC Read Status [18:0x0]: 1:57
2024-07-10 13:11:31.045106+0800 SoundCore[402:15709] Compiler failed to build request
Could not statically determine the target of a texture
Panic
in operator():97
reason: Could not create Metal pipeline state.
#0  SoundCore                              0x1039a7a7c _ZN5utils6TPanicINS_18PostconditionPanicEEC2EPKcS4_iNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE + 100
#1  SoundCore                              0x1039a77dc _ZN5utils18PostconditionPanicCI1NS_6TPanicIS0_EEEPKcS3_iNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEE + 12
#2  SoundCore                              0x1039a77bc _ZN5utils6TPanicINS_18PostconditionPanicEE5panicEPKcS4_iS4_z + 116
#3  SoundCore                              0x10387fddc _ZN8filament7backend17DepthStateCreatorclEPU19objcproto9MTLDevice11objc_objectRKNS0_17DepthStencilStateE + 0
#4  SoundCore                              0x103869b2c _ZN8filament7backend10StateCacheINS0_18MetalPipelineStateEU8__strongPU33objcproto22MTLRenderPipelineState11objc_objectNS0_20PipelineStateCreatorEN5utils4hash12MurmurHashFnIS2_EEE16getOrCreateStateERKS2_ + 364
#5  SoundCore                              0x1038736d4 _ZN8filament7backend18ConcreteDispatcherINS0_11MetalDriverEE4drawERNS0_6DriverEPNS0_11CommandBaseEPl + 1164
#6  SoundCore                              0x10384fbac _ZNSt3__110__function6__funcIZN8filament7backend13CommandStream7executeEPvE3$_0NS_9allocatorIS6_EEFvvEEclEv + 52
#7  SoundCore                              0x103874bc4 _ZN8filament7backend11MetalDriver7executeERKNSt3__18functionIFvvEEE + 44
#8  SoundCore                              0x10384f914 _ZN8filament7backend13CommandStream7executeEPv + 96
#9  SoundCore                              0x103925f40 _ZN8filament7FEngine4loopEv + 448
#10 SoundCore                              0x103929790 _ZNSt3__114__thread_proxyB7v160006INS_5tupleIJNS_10unique_ptrINS_15__thread_structENS_14default_deleteIS3_EEEEMN8filament7FEngineEFivEPS8_EEEEEPvSD_ + 64
#11 libsystem_pthread.dylib                0x1fe2302c0 <redacted> + 128
#12 libsystem_pthread.dylib                0x1fe230220 _pthread_start + 44
xiamingwei-sudo commented 1 month ago

There should be a postcondition reason printed in the logs. Can you check again and see if there's additional information about the crash?

I repeated the question, please see the log I replied above, thanks !!

bejado commented 1 month ago

We previously worked around an error like this, I wonder why this is no longer working: https://github.com/google/filament/blob/3728f0660395d04d5735d85831a43480501f1c63/shaders/src/light_indirect.fs#L75-L78

@xiamingwei-sudo are you able to investigate what the GPU's device.name is? Maybe this check isn't sufficient:

https://github.com/google/filament/blob/3728f0660395d04d5735d85831a43480501f1c63/filament/backend/src/metal/MetalDriver.mm#L165-L166

xiamingwei-sudo commented 1 month ago

We previously worked around an error like this, I wonder why this is no longer working:

https://github.com/google/filament/blob/3728f0660395d04d5735d85831a43480501f1c63/shaders/src/light_indirect.fs#L75-L78

@xiamingwei-sudo are you able to investigate what the GPU's device.name is? Maybe this check isn't sufficient:

https://github.com/google/filament/blob/3728f0660395d04d5735d85831a43480501f1c63/filament/backend/src/metal/MetalDriver.mm#L165-L166

thanks for you respons, and my ipad GPU info :

FEngine (64 bits) created at 0x120a1d800 (threading is enabled)
FEngine resolved backend: Metal
Selected physical device 'Apple A7 GPU'
Backend feature level: 2
FEngine feature level: 1

so how can i fix this issue? can you give me some suggestion ?

bejado commented 1 month ago

Perhaps we also need to extend that fix to Apple A7 GPUs. @xiamingwei-sudo can you change that check inside MetalDriver.mm to this and then recompile Filament?

    mContext->bugs.a8xStaticTextureTargetError =
            [mContext->device.name containsString:@"Apple A8X GPU"] ||
            [mContext->device.name containsString:@"Apple A7 GPU"];
xiamingwei-sudo commented 1 month ago

Perhaps we also need to extend that fix to Apple A7 GPUs. @xiamingwei-sudo can you change that check inside MetalDriver.mm to this and then recompile Filament?

    mContext->bugs.a8xStaticTextureTargetError =
            [mContext->device.name containsString:@"Apple A8X GPU"] ||
            [mContext->device.name containsString:@"Apple A7 GPU"];

Thank you very much for your reply, no more crashes after adding Apple A7 GPUs and recompiling Filament, but we also got crash on Ipad Air2/ Ipad mini 4 & iphone 6 & 6 plus , i think that is the same problem, Thanks again for your response!! and look forward to seeing the issue fixed in the release Version