Reading the documentation for `buffer-invisibility-spec' more thouroughly, it now seems to me that a better patch would be:
diff -u isearch.el~ isearch.el
--- isearch.el~ 2019-09-10 02:32:49.000000000 +0200
+++ isearch.el 2022-06-03 09:40:59.991883469 +0200
@@ -2972,7 +2972,8 @@
;; skip all characters with that same `invisible' property value.
;; Do that over and over.
(while (and (< (point) end) (invisible-p (point)))
- (if (invisible-p (get-text-property (point) 'invisible))
+ (if (or (memq (get-text-property (point) 'invisible) buffer-invisibility-spec)
+ (assq (get-text-property (point) 'invisible) buffer-invisibility-spec))
(progn
(goto-char (next-single-property-change (point) 'invisible
nil end))