For the last two days the Miui alarm has worked with this setting disabled:
Settings > Battery & Performance > Power > (Settings Button) > Clear cache when device is locked = Never
I'll test for another week to make sure. Hopefully it is the fix we have been looking for.
If you're experiencing alarm problems try this setting!
I'm trying to find information about what this setting does specifically, but I haven't found anything yet. Eg: does this completely close apps after [x] minutes of the screen being locked? How does this work with other Miui settings like app battery saver, autostart etc?
Maybe this setting could be affecting other app notifications?
I guess, crossing the finger, I solved!
This morning alarm clock worked, finally!!
I had already tried all solutions proposal: turn off every battery saver and optimization etc etc...but what worked for me is:
1)Turn ON "Miui optimization" under developer option
2) back to default Miui theme (I know, it's crazy!)
Now I have to investigate on what options I can reset to ON and if this morning was just a lucky coincidence.
I installed the WSM-Tools APK but it says it isn't compatible with the Mi5s: "WSM is not (yet) compatible with Android SDK version 23 or your processor architecture (arm64-v8a)". So I didn't install the flashable .zip, for fear I'd end up in a boot loop...
But I was able to use the app to download the "Alarmtime-Fix" module, which can be activated in Xposed.
I'm going to re-enable all other options now, as they obviously haven't fixed the problem.