Chap 3 Resourses: MetalView.Swift seems to be hanging my mac

Hi there

I’ve has a disastrous 24 hours with my mac powerbook crashing.
I was revisiting Metal in the updated v3 book to integrate it with SwiftUI. Chapter 3 suggest loading the MetalView.Swift and dragging it to my project.

As soon as I did, my computer hung. Naturally I did not suspect this operation so I’ve done a ton of other things to fix it, freeing up memory, running the disk utility, etc. Each time I thought my computer was clear, I dragged the file again. Each time it hung. I went so far as reloading my operating system and re-downloading the metal materials from your site. Everything looked hunky dory until I dragged in your file. Then … disaster

Maybe the problem is something else but it seems to me after literally hours of work that I only hang when I drag your file. Could you please investigate?

regards

That’s very frustrating for you. I don’t know quite what to suggest, as it works perfectly for me on my M1 Mac mini.

What device / operating system / Xcode version are you using?

Have you tried running the supplied final project? Does it work?

Instead of dragging the file in, what happens if you create a new Swift file in Xcode, open MetalView.swift in TextEdit, and copy the code from MetalView.swift to the new Swift file in Xcode?

1 Like

Hi Caroline

Macbook pro mid-21015
Monterey 12.6.3
Xcode Ver 14.2 (14C18)

I did try copying and pasting from GitHub and that failed too, in exactly the same way. What’s really puzzling is that all the crashes occur as soon as the file is created. There is no need to compile and run them. Strange!! (This is why I’m not sure your code is the problem but the only way I’ve managed to replicate it is to grab your code. I’m thinking of bringing it onto Penn & Teller Fool Us :grinning:)

I haven’t tried on the final project yet but I will when I get back to my desk.

I have however built my own version of MetalView (conforming to UIViewRepresentable) before I ever looked at your v3 book and it worked well and indeed it still works!!!

regards

OK. My computer is cleaned up (RW metal materials binned) and working fine on all my own stuff.
I managed to make a copy of MetalView.Swift using copy|paste and it works.

But … even now … I can still replicate the problem as follows.

  1. download RW metal materials from GitHub
  2. simply click on MetalView.Swift in chapter 3 resources

Conclusion: there is something not nice in there.

Thank you Caroline for your very fast response.

I hope you are able to move forward from this. I still can’t replicate it after redownloading the source, but I am on a much newer M1 computer, with Ventura. (My computer has its own crashing problems too, but not this one.)

If anyone else reading this has this problem, or doesn’t have this problem, please post your experience. Thanks.

1 Like

Hello Caroline
You’ve been so helpful in this forum. Thank you.

Yesterday was a disaster, my mac repeatedly hanging as described above. However I’m now 95% sure the problem is in your repository.

The problem only manifests when I try to enter your downloaded directory in my Finder. So yesterday I booted in SafeMode, entered terminal to delete the contents of my download folder (deleting the folder itself was not permitted). I re-downloaded your repository and by extra caution moved the package out of the Download folder. Then I went into the finder, chapter 7 or 8 (I forget) and CRASHHHHHH.

This morning I noticed that my iCloud synch was hanging. With the help of this link I identified the blockage was in your download. Delete the lot and iCloud synch clears. I think there may be something in there which iCloud is rejecting.

One suggestion in the link was duplicate file-names. To test this, while I was writing this message, I again downloaded your package. I just went over to look at it. When I did … another CRASH.

I’m back in SafeMode now to finish this report. I’m absolutely sure that EVERY crash I’ve had this month has been when I entered your downloaded files in the Finder. It may or may not be iCloud connected but iCloud doesn’t like something either.

I suppose I could abandon Metal by Tutorials but I’m enjoying learning from it. Is there any way you can spot something amiss is your files or reconstitute them?

BTW I’m running Mac Monterey (12.6.5) (new machine in the budget imminently :slight_smile: ) and it doesn’t seem to allow me to switch off iCloud … no button!!!

Thanks so much

I’ll have a look at it tomorrow by placing everything in my iCloud.

I don’t sync Desktop or Documents with iCloud. That’s one of the options that appear when you installed Monterey. Do you have any folders that you aren’t syncing with iCloud that you could put the repo in?

The repository is pretty big. What iCloud limits do you have? Ie do you pay for extra iCloud storage and are you near your iCloud limits?

I would hate for you to give up for this reason. I’m sure we can work something out. Maybe even place the repo on an external drive?

Don’t worry Caroline. I’ll not give up (I’m just a hobbyist doing this for personal amusement but it is interesting.)

I have 2TB of iCloud so space is not the thing. I synch Docs and Desktop but I’m pretty sure Downloads don’t. This is why the download doesn’t have immediate consequences, until I try bringing it elsewhere.

Don’t waste too much time Caroline. After a lot of pain, I now have your repository sitting in a directory in Desktop and as long as I remember to treat it with TLC (no loud noises), I am managing not to crash it. It has even completed its synch with iCloud.

However, I’m not at all clear what iCloud does. I have no button to suspend it from working (as shown on all help sites). If I switch off iCloud drive I get a warning (threat?) that all files will be removed from my mac and as I don’t know what that means, I don’t dare do it!!! My Finder has a directory iCloud Drive which I assume is the iCloud copy of my drive but it has an empty Downloads directory. Why on earth if I cut off iCloud Drive would my local files be removed. That looks like downright theft to me.

Indeed I am so bothered about how my files are stored that when I purchase my next machine I will not let it have any connection to the present one. I’ll have to migrate files manually over time.

This is what I tried:

  1. Download and extract the zip file from Github
  2. Move the folder from Downloads to a new folder in iCloud
  3. Wait for files to upload to iCloud (406MB)
  4. Right click folder and choose Remove Download
  5. Open and build and run projects in Chapters 7 and 8 (projects download from iCloud on opening)

It all worked fine for me. But I don’t have Desktop and Documents in iCloud, only iCloud Drive available to me. And I’m working on an Apple Silicon Mac mini running Ventura, which may be significant.

I have never really trusted relying on syncing my precious files with iCloud, so have never connected Desktop and Documents to iCloud. However, I watched an explainer video, and the process seems to be very smooth, so I might reconsider for those projects where I work on multiple computers.

Video here:

He demonstrates what happens when you unsync Desktop and Documents. (If you do that, I take no responsibility for what happens :stuck_out_tongue: ).

A better option than unsyncing is at 08:52, he explains what you can do if you want documents that don’t sync with iCloud. (You create a local folder in your home folder.) That’s an option you could try if everything keeps crashing.

Caroline you’re a champion!!
That video was very helpful.

I guess it really is time to upgrade my old mac.

Have a great day!