Skip to content

Crash when buffer is empty / SwiftUI #2

Open
@matts9000

Description

@matts9000

macOS Version(s) Used to Build

macOS 13 Ventura

Xcode Version(s)

Xcode 14

Description

Hello,

I experience crashes with invalid NIL in the following function of Renderer.swift:

func selectBuffers(width: CGFloat) -> (MTLBuffer, MTLBuffer) {
    var level = 0
    for (minBuffer, maxBuffer) in zip(minBuffers, maxBuffers) {
        if CGFloat(minBuffer.length / MemoryLayout<Float>.size) < width {
            return (minBuffer, maxBuffer)
        }
        level += 1
    }

    **return (minBuffers.last!, maxBuffers.last!)**
}

I tried to reproduce this in debug mode, but I does not happen there - it happens only with the app compiled for run.
What I see is that in debug the drawing is much slower. So what I suspect is, that as I'm using SwiftUI redraws happen with empty buffers, which cause this.

BTW: thanks for this wonderful implementation of a waveform drawer!

Crash Logs, Screenshots or Other Attachments (if applicable)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions