SwiftUI PKCanvasView bounds

I am creating a Bible app with SwiftUI using Text in the background and a PKCanvasView in the front to mark the text and take notes. The user can modify the font and its size and you can navigate to different books and chapters. Each chapter's text has a different size causing the PKCanvasView to have varying sizes. The width of the canvas is always the same but the height changes based on these parameters I just mentioned. If the chapter is long and the height of the canvas exceeds 4000 or some settings cause the text to make the views bound to go beyond 4000, the drawing will enlarge or appear to be occurring in a different location than my pencil. As soon as I lift my pencil, the drawing snaps to the place it belongs.

var body: some View {
        HStack(spacing: 0) {
            // Main content container
            ScrollView {
                ZStack {
                    // Text content
                    VStack {
                        if let chapter = viewModel.currentChapterText {
                            HStack {
                                Text(AttributedString(chapter.html(fontName: fontName, fontSize: fontSize, showVerses: showVerse, showFootnotes: showFootnotes)))
                                    .padding()
                                    .frame(width: textWidth, alignment: .leading)
                                Color.clear
                            }
                            .frame(width: canvasWidth)
                        } else {
                            Text("Select a book to begin reading")
                                .foregroundColor(.gray)
                        }
                    }
                    
                    // Drawing canvas overlay
                    if showingDrawingTools {
                        DrawingCanvasView(
                            canvasView: $canvasView,
                            toolPicker: toolPicker,
                            frame: CGSize(width: deviceWidth, height: deviceHeight),
                            onSave: saveDrawing
                        )
                    }
                }
            }
        }
        .onChange(of: viewModel.currentChapter) { oldValue, newValue in
            print("BibleContentView - chapter text changed")
        }
    }

@papajybp Could you please clarify which Apple API you are having issues and the steps you've taken to debug the issue. That would help us understand the specific issue.

For additional tips on creating Apple Developer Forums posts, see tips on writing forums posts.

I am using PKCanvasView with a UIViewRepresentable name DrawingCanvasView. I have looked at ways to split a canvas I am loaded and have gotten that to work. But while drawing if I cross canvases I don't see the drawing on a new canvas. I have tried updating the contentSize to match the height of the Text view but still there are limits to how large a PKCanvasView can be.

SwiftUI PKCanvasView bounds
 
 
Q