Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime warnings #49

Open
3 tasks done
arnauddorgans opened this issue Mar 6, 2024 · 2 comments
Open
3 tasks done

Runtime warnings #49

arnauddorgans opened this issue Mar 6, 2024 · 2 comments
Labels
bug Something isn't working due to a bug in the library.

Comments

@arnauddorgans
Copy link

arnauddorgans commented Mar 6, 2024

Description

This code snippet produces 3 runtime warnings on appear about Perceptible state was accessed but is not being tracked. Track changes to state by wrapping your view in a 'WithPerceptionTracking' view.

@Perceptible
class FeatureModel {
    var text = ""
}

struct ContentView: View {
    @Perception.Bindable var model: FeatureModel

    var body: some View {
        WithPerceptionTracking {
            TextField("", text: $model.text)
                .background(GeometryReader { proxy in
                    Color.clear
                        .randomModifier(of: proxy.safeAreaInsets)
                })
        }
    }
}

Checklist

  • I have determined that this bug is not reproducible using Swift's observation tools. If the bug is reproducible using the @Observable macro or another tool from the Observation framework, please file it directly with Apple.
  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue or discussion.

Expected behavior

No runtime warning

Actual behavior

Runtime warning

Steps to reproduce

Full app code

@Perceptible
class FeatureModel {
    var text = ""
}

struct ContentView: View {
    @Perception.Bindable var model: FeatureModel

    var body: some View {
        WithPerceptionTracking {
            TextField("", text: $model.text)
                .background(GeometryReader { proxy in
                    Color.clear
                        .randomModifier(of: proxy.safeAreaInsets)
                })
        }
    }
}

extension View {
    @ViewBuilder
    func randomModifier<T>(of value: T) -> some View where T: Equatable {
        if #available(iOS 17.0, *) {
            self
        } else {
            fatalError() // We don't care here
        }
    }
}

@main
struct TCABugApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView(model: .init())
        }
    }
}

Perception version information

1.1.2

Destination operating system

iOS 14.0

Xcode version information

Xcode 15.3

Swift Compiler version information

swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0
@arnauddorgans arnauddorgans added the bug Something isn't working due to a bug in the library. label Mar 6, 2024
@stephencelis
Copy link
Member

@arnauddorgans I can't seem to reproduce this on 1.1.3 / main. Can you confirm that it's been fixed and close this out, or can you please submit a failing test case?

@stephencelis
Copy link
Member

Ah never mind, I couldn't reproduce it in our unit test suite but I was able to reproduce it in an app. Very strange! Will look into it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working due to a bug in the library.
Projects
None yet
Development

No branches or pull requests

2 participants