2 Replies
      Latest reply on Jun 19, 2019 9:00 AM by mikesand
      dbradley645 Level 1 Level 1 (0 points)

        I have been working throught the SwiftUI demo code tasks from this website and up until now have not had an issue. On the most recent step (https://developer.apple.com/tutorials/swiftui/handling-user-input Section 2 Part 2), I attempted to run the application using the new Canvas feature, only for the canvas preview to start consistently crashing (even with the code added in that section commented out), but when you ask for the Diagnostics the error code is mainly: "Landmarks.app: no underlying error". There is though sometimes the error: "Landmarks.app: Error Domain=render service Code=12 "Rendering service was interrupted" UserInfo={NSLocalizedDescription=Rendering service was interrupted}", which I can't locate online anywhere other than one chinese language website. Has anyone any idea wether this is something to do with the code I've been writing or is this a bug in SwiftUI in XCode 11 Beta? Or any suggestions on a fix? Thanks in advance! (NOTE: Xcode 11 beta  (11M336w) and the first release of MacOS 10.15 Beta are both being used on this)

        • Re: Error (but no error) with Canvas when trying to run SwiftUI Landmark
          mikesand Level 1 Level 1 (0 points)

          Had the same issue. Are you by any chance doing the tutorial on a MacBookPro?

           

          The Swift UI tutorials experience of right panel code example changing and highlighting changes as you scroll the instructions on the left is innovative and generally works, but has some drawbacks. One is that if the code example on the right is too big to fit in the window, there's no way to know that. Following convention since 10.7 Lion, the scrollviews are hidden until you start to scroll.

           

          So when you get to "Handling User Input" Section 5 Step 5, there's no good way to know that if on a MacBookPro 15" Safari at default resolution and size, apparantly, you need to scroll down and see additional changes that you need to make to the "PreviewProvider" in order for the preview to work.

           

          That the error message blames your app -- your app "may have crashed" is just user-hostile. The app builds and runs, it's the preview that has crashed, and astonishing they can't surface that information in the UI or crash reports but defualt to text blaiming the app.  I only found it by running the tutorial that was crashing and the "complete" project provided through diff tool FileMerge.

          But that no one did the tutorials on a MacBookPro 15" to see this problem is just come on.

            • Re: Error (but no error) with Canvas when trying to run SwiftUI Landmark
              mikesand Level 1 Level 1 (0 points)

              After looking again, a few points.

               

              First, If the EnivronmentObject is not provided, the code has crashed, so in that sense the warning is accurate.

              However, it's misleading to say "YourApp.app" may have crashed, since the preview does not go through the app's normal control flow. It starts at the PreviewProvider. Since the PreviewProvider is a concrete type, it would be better to say `LandmarkList_Previews has crashed` or just otherwise name-check the specific PreviewProvider (instead of "Cannot preview in this file" so that we can know to start looking in the preview.

               

              Really, best case would be the missing EnivronmentObject should be detectable at compile time, though I don't know how that would work.  Notably, the crash happens even if the EnvironmentObject is not used anywhere in the body. Also, when running the actual app target, if the EnivronmentObject is not set on the rootView of the UIHostingController that is the window's rootViewController, then the crash happens on makeKeyAndVisible; anywhere else, the crash just goes to UIApplicationMain. Regardless, a missing EnvironmentObject object at runtime should be able to determe that and trap with that message, not fail on an error with StoreBox.