Skip to content

Commit 7dac763

Browse files
authored
Fix for OpenMP thread affinity crashes on Android devices (#1521)
1 parent 8afc9ac commit 7dac763

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/synth/fluid_synth.c

+15
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,21 @@ fluid_synth_init(void)
300300
#endif
301301
#endif
302302

303+
/*
304+
* Disable OpenMP thread affinity on Android to prevent crashes.
305+
*
306+
* On several Android devices (particularly Xiaomi), OpenMP's attempt to set thread
307+
* affinity fails with EINVAL, causing process abortion during parallel SoundFont loading.
308+
* This is due to an unresolved bug in Android NDK's OpenMP implementation
309+
* (see https://github.com/android/ndk/issues/1180).
310+
*/
311+
#ifdef __ANDROID__
312+
if (setenv("KMP_AFFINITY", "disabled", 1) != 0)
313+
{
314+
FLUID_LOG(FLUID_WARN, "Failed to disable KMP_AFFINITY, OpenMP crashes may occur on some devices!");
315+
}
316+
#endif
317+
303318
init_dither();
304319

305320
/* custom_breath2att_mod is not a default modulator specified in SF2.01.

0 commit comments

Comments
 (0)