-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
Crash when stroking a circle #322
Comments
The issue appears to have something to do with the environment not being correctly propagated to the |
…s applied, and added a mention to issue #322
A bit more info that may or may not be of use for debugging: Depending on how types are wrapped on the call site, the environment is either injected correctly or not. The lines marked with '// crashes' are those that don't get the environment injected. struct MyShape: Shape {
func path(in rect: TokamakGTK.CGRect) -> Path {
var path = Path()
path.addEllipse(
in: CGRect(origin: .zero, size: .init(width: 100, height: 150)),
transform: TokamakCore.CGAffineTransform(rotationAngle: 0.5)
)
return path.applying(TokamakCore.CGAffineTransform(rotationAngle: -0.1))
}
}
struct MyStrokedShape: View {
var body: some View {
MyShape()
.stroke(
Color.red,
style: StrokeStyle(lineWidth: 4, lineCap: .round, lineJoin: .round, dash: [5, 5, 1])
)
}
}
struct MyStrokedAndFramedShape: View {
var body: some View {
MyShape()
.stroke(Color.red)
.frame(width: 50, height: 200)
}
}
struct TokamakGTKDemo: App {
@State var text: String = "Test"
var body: some Scene {
WindowGroup("Test Scene") {
MyShape()
.frame(width: 50, height: 200) // works
MyShape()
.stroke(Color.red)
.frame(width: 50, height: 200) // crashes
MyStrokedShape()
.frame(width: 50, height: 200) // works
MyStrokedAndFramedShape() // crashes
}
}
} |
Based on that, I wonder if |
Well, |
Hi again @j-f1 , But I don't quite get the relationship between the |
@carson-katri I think you introduced |
The PR fixes multiple bugs which prevent stroked shapes from rendering correctly. 1. Allow environment injection into `_StrokedShape`. This causes stroked shapes to no longer crash (#322). 2. Change `Path.strokedPath` and `Path.trimmedPath` to allow the `sizing` of the base shape to be inherited. Without this, stroked shapes can appear as 0x0 in size, making them invisible. 3. Change `_ShapeView` in the StaticHTML renderer to merge attributes in the `svg` rather than placing the `svg` in a `div`. This allows proper rendering when multiple shapes are in a stack. Finally, the `Path` demo has been modified to add a stroked circle.
@ezraberch can we close this as completely resolved by #414? |
Sure. |
The following code:
produces this error. Explicitly specifying
.colorScheme(.light)
does not help.The text was updated successfully, but these errors were encountered: