kvic-z / SsdPmEnabler

104 stars 5 forks source link

SsdPmEnabler and/or the absence of full SIP causes Apple Photo curation and face-detection to be stuck forever #18

Open porg opened 2 years ago

porg commented 2 years ago

Foreword

Environment

Reproduction

Side effect: Apple Photos stopped curation and face-detection. It is stuck forever.

Fix for side effect: Re-enable SIP and/or uninstall 3rd party Kernel extension SsdPmEnabler

Questions arising from this

  1. Is it the absence of a full SIP which prevents photoanalysisd to work normally?
  2. Is it the presence of an unsigned 3rd party kernel extension in general?
  3. Is it a specific malfunctioning of the kernel extension SsdPmEnabler in particular?
    • After all it deals with power savings for a 3rd party NVM SSD.
    • What could go wrong in that regard which affects daemon processes such as photoanalysisd particularly configured to run only when the system is "almost or mostly idle"?
    • Maybe it is messing in undesired/unintended ways with power assertions? See manpages on caffeinate and pmset in particular pmset -g assertions. And as a consequence the power state which certain daemons like photoanalysis wait for never kicks in, hence they never run (fully).
kvic-z commented 2 years ago

Your investigation looks flawed to me.

1) Have you tried kept SIP partially disabled AND ssdpmEnabler uninstalled ? But seems now it's too late to test this scenario (?) since you already passed the initial stuck issue in photoanalysisd

2) Disable SIP partially and re-install ssdpmEnabler again. Will photoanalysisd get stuck again?

porg commented 2 years ago

I'm already quite sure, because I had so many other attempts to fix Apple Photos please see them to see what effort I made to rule out the reason to be not in the SIP / kext / power-management / SsdPmEnabler department.

But I'm willing to do one more round of intensive testing. From your two points I assume you want to find out whether the absence of full SIP alone causes this, or whether the actively running ssdpmEnabler.kext.

Ad 1) AFAIR after uninstalling ssdPmEnabler I soon later rebooted into Recovery and there re-enabled SIP.

Ad 2) My idea is to add a further intermediate step to be even more sure. What about this test procedure:

  1. reboot ; csrutil enable --without kext ; reboot -- State: SIP partially disabled, no unsigned kexts installed
  2. Load new pictures into Apple Photos (anyhow have that in my work queue now, would fit)
  3. Observe whether curation and face detection is done within reasonable time (1-2 days with enough idle time inbetween, if nothing within the first day, give it one overnight with sleep turned off).
    • If curation/face-detections remains stuck, then we know it is the absence of full SIP per se.
    • If it worked fine we continue with the next test.
  4. Install ssdPmEnabler ; reboot ; check whether running, if necessary authorize again. -- State: SIP partially disabled, one unsigned kexts installed and running which is ssdPmEnabler
    • Repeat 2+3. If curation/face-detection works, then it's not SsdPmEnabler.
    • If it remains stuck for 2 days with enough idle time (one sleepless night) it is ssdPmEnabler (or what it causes indirectly regarding power/idle states/conditions) with a high probability.
kvic-z commented 2 years ago

To help your investigation, I would like you get your concept right about ssdpmEnabler. It's a tool (alas a kext) that enables a piece of hardware feature. It's not some sort of service or process that will continously running in the background. It finishes its job in less than 1s. Then will not intervene any other running processes.

Hence, your claim against ssdpmEnabler or 3rd party kexts interveneing photoanalysisd is a bit on the long shot.

Your other claim that disabling SIP might intervene in photoanalysisd is more plausible than the above one.

IMHO, if it's indeed related to power state of your P2, then likely some changes in the OS that causes incompatibility of 3rd party NVMe m.2 with photoanalysisd after certain version of Big Sur update as you've experienced. The incompatibility could be P2 specific (Phison E13T controler) or perhaps 3rd party NVMe controllers in general.

porg commented 2 years ago

Thanks a lot for the conceptual clarification, specifically that ssdPmEnabler per session does it's job as a oneshot operation and then keeps quiet, not running as a constantly active background job.

So what remains as plausible for photoanalysisd being stuck:

porg commented 2 years ago

One more idea, relevant for both #18 and #19 and ssdPmEnabler as a whole

mnerd commented 2 years ago

For me, photoanalysis stops after partial off SIP, without any kext loaded. Macbook Pro 2015, firmware 428.60.3.0.0, BigSur 11.6.5 (20G527), Samsung 970 Pro 1 TB with latest firmware

porg commented 2 years ago

Finally some news!

So what can we do about it?

  1. Write a warning into the readme that "disabling SIP was reported twice (porg, mnerd) to have the undesired side effect that Apple Photos face-detection and curation stop working (photoanalysisd never kicking in)".
  2. Report our suspicion to Apple? I could report first. Then share my feedback ID and you @mnerd report it again, and state me and my feedback ID as a reference.
porg commented 3 months ago

Close this?