bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.27k stars 3.58k forks source link

Android: segfault on some devices when shadows are enabled #8214

Open mockersf opened 1 year ago

mockersf commented 1 year ago

Bevy version

4f16d6e0dc14c12ab29b72880d5d3d22003eed72

[Optional] Relevant system information

Not all devices are concerned, from some tests:

AdapterInfo { name: "Adreno (TM) 610", vendor: 20803, device: 100728833, device_type: IntegratedGpu, driver: "Qualcomm Technologies Inc. Adreno Vulkan Driver", driver_info: "Driver Build: 5eaa426211, I07ee46fc66, 1633700387\nDate: 10/08/21\nCompiler Version: EV031.32.02.16\nDriver Branch: \n", backend: Vulkan }
SystemInfo { os: "Android 11 2201117TI", kernel: "4.19.157-perf-g8cd144836769", cpu: "", core_count: "8", memory: "3.6 GiB" }

What you did

Running example bevy_mobile

What went wrong

It crashes with a segfault.

Additional information

Disabling the shadows on the PointLight makes it not crash

03-25 14:22:56.126 W/ActivityThread( 2537): registerApplicationScoutThread result:true
03-25 14:22:56.138 W/System  ( 2537): ClassLoader referenced unknown path: 
03-25 14:22:56.150 I/Perf    ( 2537): Connecting to perf service.
03-25 14:22:56.166 D/AnrScout( 2537): AppScoutStateMachine created
03-25 14:22:56.166 I/ForceDarkHelper( 2537): packageName:org.bevyengine.example getForceDarkConfigInfo null  forceDarkAppConfigJsonString:null
03-25 14:22:56.166 I/ForceDarkHelper( 2537): ForceDarkConfigInfo: null
03-25 14:22:56.169 I/MiuiForceDarkConfig( 2537): MiuiForceDarkConfig setConfig density:2.750000, mainRule:17, secondaryRule:0, tertiaryRule:0
03-25 14:22:56.171 D/NetworkSecurityConfig( 2537): No Network Security Config specified, using platform default
03-25 14:22:56.171 D/NetworkSecurityConfig( 2537): No Network Security Config specified, using platform default
03-25 14:22:56.207 D/View    ( 2537): org.bevyengine.example initForcedUseForceDark: 1
03-25 14:22:56.226 D/DecorView[]( 2537): getWindowModeFromSystem  windowmode is 1
03-25 14:22:56.273 I/yengine.exampl( 2537): Explicit concurrent copying GC freed 133043(7374KB) AllocSpace objects, 2(40KB) LOS objects, 24% free, 2009KB/2679KB, paused 574us total 27.720ms
03-25 14:22:56.374 W/linker  ( 2537): Warning: "/data/app/~~leZhNzeIANE84QmOTrXj_g==/org.bevyengine.example-LkjUbom0XvdVlcMbf0WuyA==/lib/arm64/libc++_shared.so" unused DT entry: unknown processor-specific (type 0x70000001 arg 0x0) (ignoring)
03-25 14:22:56.465 D/vulkan  ( 2537): searching for layers in '/data/app/~~leZhNzeIANE84QmOTrXj_g==/org.bevyengine.example-LkjUbom0XvdVlcMbf0WuyA==/lib/arm64'
03-25 14:22:56.466 D/vulkan  ( 2537): searching for layers in '/data/app/~~leZhNzeIANE84QmOTrXj_g==/org.bevyengine.example-LkjUbom0XvdVlcMbf0WuyA==/base.apk!/lib/arm64-v8a'
03-25 14:22:56.499 I/AdrenoVK-0( 2537): ===== BEGIN DUMP OF OVERRIDDEN SETTINGS =====
03-25 14:22:56.499 I/AdrenoVK-0( 2537): ===== END DUMP OF OVERRIDDEN SETTINGS =====
03-25 14:22:56.500 I/AdrenoVK-0( 2537): QUALCOMM build          : 5eaa426211, I07ee46fc66
03-25 14:22:56.500 I/AdrenoVK-0( 2537): Build Date              : 10/08/21
03-25 14:22:56.500 I/AdrenoVK-0( 2537): Shader Compiler Version : EV031.32.02.16
03-25 14:22:56.500 I/AdrenoVK-0( 2537): Local Branch            : 
03-25 14:22:56.500 I/AdrenoVK-0( 2537): Remote Branch           : 
03-25 14:22:56.500 I/AdrenoVK-0( 2537): Remote Branch           : 
03-25 14:22:56.500 I/AdrenoVK-0( 2537): Reconstruct Branch      : 
03-25 14:22:56.500 I/AdrenoVK-0( 2537): Build Config            : S P 10.0.7 AArch64
03-25 14:22:56.500 I/AdrenoVK-0( 2537): Driver Path             : /vendor/lib64/hw/vulkan.adreno.so
03-25 14:22:56.505 I/event crates/bevy_render/src/renderer/mod.rs:128( 2537):  AdapterInfo { name: "Adreno (TM) 610", vendor: 20803, device: 100728833, device_type: IntegratedGpu, driver: "Qualcomm Technologies Inc. Adreno Vulkan Driver", driver_info: "Driver Build: 5eaa426211, I07ee46fc66, 1633700387\nDate: 10/08/21\nCompiler Version: EV031.32.02.16\nDriver Branch: \n", backend: Vulkan }
03-25 14:22:56.711 I/OboeAudio( 2537): openStream() OUTPUT -------- OboeVersion1.7.0 --------
03-25 14:22:56.716 I/AAudio  ( 2537): AAudioStreamBuilder_openStream() called ----------------------------------------
03-25 14:22:56.716 I/AudioStreamBuilder( 2537): rate   =  44100, channels  = 2, format   = 5, sharing = SH, dir = OUTPUT
03-25 14:22:56.716 I/AudioStreamBuilder( 2537): device =      0, sessionId = -1, perfMode = 10, callback: ON with frames = 0
03-25 14:22:56.716 I/AudioStreamBuilder( 2537): usage  =      1, contentType = 2, inputPreset = 6, allowedCapturePolicy = 0
03-25 14:22:56.716 I/AudioStreamBuilder( 2537): privacy sensitive = false
03-25 14:22:56.716 D/AudioStreamBuilder( 2537): build() MMAP not used because AAUDIO_PERFORMANCE_MODE_LOW_LATENCY not requested.
03-25 14:22:56.716 D/yengine.exampl( 2537): PlayerBase::PlayerBase()
03-25 14:22:56.717 D/AudioStreamTrack( 2537): open(), request notificationFrames = 0, frameCount = 0
03-25 14:22:56.717 D/AudioTrack( 2537): set(): streamType -1, sampleRate 44100, format 0x5, channelMask 0x3, frameCount 0, flags #2, notificationFrames 0, sessionId 0, transferType 1, uid -1, pid -1
03-25 14:22:56.740 D/AudioTrack( 2537): setVolume(161): 0xb4000077543c3a00, left = 1.000000, right = 1.000000
03-25 14:22:56.740 D/AAudioStream( 2537): setState(s#1) from 0 to 2
03-25 14:22:56.742 I/AAudio  ( 2537): AAudioStreamBuilder_openStream() returns 0 = AAUDIO_OK for s#1 ----------------
03-25 14:22:56.742 D/AAudio  ( 2537): AAudioStream_requestStart(s#1) called --------------
03-25 14:22:56.742 D/AAudioStream( 2537): setState(s#1) from 2 to 3
03-25 14:22:56.742 D/AudioTrack( 2537): start(161): prior state:STATE_STOPPED
03-25 14:22:56.752 D/yengine.exampl( 2537): PlayerBase::start() from IPlayer
03-25 14:22:56.752 D/AAudio  ( 2537): AAudioStream_requestStart(s#1) returned 0 ---------
03-25 14:22:56.752 D/AudioStreamLegacy( 2537): onAudioDeviceUpdate(deviceId = 3)
03-25 14:22:56.753 E/event crates/bevy_gilrs/src/lib.rs:26( 2537):  Failed to start Gilrs. Gilrs does not support current platform.
03-25 14:22:56.754 W/log event( 2537):  TODO: forward onStart notification to applicationlog.target = "winit::platform_impl::platform"; log.module_path = "winit::platform_impl::platform"; log.file = "winit-0.28.3/src/platform_impl/android/mod.rs"; log.line = 449;
03-25 14:22:56.755 W/Activity( 2537): Slow Operation: Activity org.bevyengine.example/android.app.NativeActivity onStart took 339ms
03-25 14:22:56.762 I/yengine.exampl( 2537): Explicit concurrent copying GC freed 4496(238KB) AllocSpace objects, 3(60KB) LOS objects, 24% free, 1955KB/2607KB, paused 75us total 14.805ms
03-25 14:22:56.832 W/Looper  ( 2537): PerfMonitor looperActivity : package=org.bevyengine.example/android.app.NativeActivity time=0ms latency=710ms running=0ms  procState=2 ClientTransaction{ callbacks=[android.app.servertransaction.TopResumedActivityChangeItem] } historyMsgCount=3 (msgIndex=2 wall=51ms seq=2 running=32ms runnable=2ms late=8ms h=android.app.ActivityThread$H w=110) (msgIndex=3 wall=654ms seq=3 running=92ms runnable=29ms io=6ms late=56ms h=android.app.ActivityThread$H w=159)
03-25 14:22:56.855 D/FrameIndicator( 2537): support status: 1 0x76ea899018 0x76ea8994c4
03-25 14:22:56.860 I/event crates/bevy_winit/src/system.rs:51( 2537):  Creating new window "Bevy App" (0v0)
03-25 14:22:56.862 I/event crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs:130( 2537):  SystemInfo { os: "Android 11 2201117TI", kernel: "4.19.157-perf-g8cd144836769", cpu: "", core_count: "8", memory: "3.6 GiB" }
03-25 14:22:56.874 D/AAudioStream( 2537): setState(s#1) from 3 to 4
03-25 14:22:58.171 E/LB      ( 2537): fail to open file: No such file or directory
03-25 14:22:58.185 F/libc    ( 2537): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8 in tid 2618 (Compute Task Po), pid 2537 (yengine.example)
03-25 14:22:59.154 I/ActivityManager( 1681): Process org.bevyengine.example (pid 2537) has died: prcp TOP 

https://user-images.githubusercontent.com/8672791/227744123-7acf73c3-e2db-4078-b93f-17851dc376fa.mp4

Philipp-M commented 1 year ago

Thanks for investigating this. I have reproduced this on an LG V30 (enabling/disabling shadows in the PointLight):

AdapterInfo { name: "Adreno (TM) 540", vendor: 20803, device: 84148225, device_type: IntegratedGpu, driver: "?", driver_info: "?", backend: Vulkan }
SystemInfo { os: "Android 9 LG-H930", kernel: "4.4.153-perf+", cpu: "", core_count: "8", memory: "3.6 GiB" }
TotalKrill commented 1 year ago

Can someone with these devices, see if applying the fixes for webgl, fixes the same issue here? Since I can see that cascaded shadow maps and the shaders for shadows that reference the directional lights that previosly was an issue for adreno gpu in wasm and webgl.

this: https://github.com/bevyengine/bevy/pull/8508

Just have a small suspicion that this might be the same bug here.