Good question and I remember a long time ago reading about how "pinhole" photography solved this problem. "Pinhole" photography could make the entire photograph in focus. IIRC, it took outdoor lighting or special lighting due to the small aperture, but the results were amazing.
I was really into camera photography back in the 70's and beyond and have tons of 35mm family photos. Then came the advent of the DLS camera which made film developing a thing of the past (for me). Then the pocket cameras took such good photos it obsoleted my DLS and was much easier to carry.
BUT, the iPhone blew everything away. The company bought senior management iPhone 11's back in the 20 teens and the wife upgraded us to the 13's just before we retired and what a game changer. No more out of focus DLS photos (mostly model trains by this time) and I can only imagine how much improved the newer model iPhones are.
Sorry, I didn't mean to hijack the thread.
