You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(Hello, this is my first issue in swiftlang/swift so I apologize in advance if I've put it somewhere incorrect or made mistakes/omissions in the report! @rauhul suggested creating this issue for review and tagging him and @kubamracek. Thank you for looking!)
Description
Using a class that contains a struct (with certain properties) within a Playdate game built with Swift Embedded, the game crashes when that class instance is deallocated.
System Crash Report
(Pease let me know if there are other sections from the report I shouldinclude!)
(⚠️EDIT June 25th, 1:10pm Pacific: Updated example to use swift-playdate-examples instead, as it removes a dependency on a different third-party library.)
Unfortunately, I don't yet have an individual snippet of Swift code that reproduces this issue without involving a Playdate game. I've tried to make this happen outside of a game still using Swift Embedded but haven't found something that crashes yet. I'll keep working on that and post an update here if/once I have something.
(This, of course, suggests the issue might not be with Swift Embedded- I'm mentioning it in case it is, as the conditions that cause it (and those that 'prevent' it) are fairly odd and are almost completely using 'plain' Swift types. All that said, if this issue should be closed for that reason, I fully understand!)
Ensure the Playdate Simulator (2.5.0 a.k.a latest) is installed
Open Examples/MyGame in XCode
Build and run
Wait approximately 2.5 seconds for the first crash
(Copying the contents of Game.swift from the branch here as well:)
import Playdate
// Ways to 'prevent' crash:
// 1. Change Thing from struct to class
// 2. Remove either of the two String properties from Thing struct
// 3. Remove currentThing from SceneWithThing
structThing{letid:Stringletname:Stringletlength:Intinit(id:String, name:String, length:Int){self.id = id
self.name = name
self.length = length
}}classSceneBase{func onSceneUpdate(deltaTime:Float)->Void{}}classSceneWithThing:SceneBase{varcurrentThing:Thing=Thing(id:"A", name:"Cool Thing", length:42)vartotalElapsed:Float=0.0overridefunc onSceneUpdate(deltaTime:Float){
totalElapsed += deltaTime
Graphics.fillRect(x:0, y:0, width:400, height:240, color:1)Graphics.fillRect(x:20, y:140, width:CInt(totalElapsed *10.0), height:50, color:0)}}structGame{varcurrent:SceneBasevarlastElapsedTime:Float=0varswitchSceneTimer:Float=0init(){
// Setup the device before any other operations.
srand(System.getSecondsSinceEpoch(milliseconds:nil))Display.setRefreshRate(rate:50)
current =SceneWithThing()}mutatingfunc updateGame(){letelapsedTime=System.elapsedTime
letdeltaTime= elapsedTime - lastElapsedTime
lastElapsedTime = elapsedTime
current.onSceneUpdate(deltaTime: deltaTime)
switchSceneTimer += deltaTime
if switchSceneTimer >2.5{
// Crash happens during the next line:
current =SceneWithThing()
switchSceneTimer =0}System.drawFPS(x:0, y:0)}}
Expected behavior
The app/Playdate Simulator should not crash 😄.
Environment
Apple Swift version 6.0-dev (LLVM 57177aa1b91540b, Swift 8be6286)
Target: arm64-apple-macosx14.0
(swift-DEVELOPMENT-SNAPSHOT-2024-06-13-a.xctoolchain, latest as of posting this issue)
Additional information
No response
The text was updated successfully, but these errors were encountered:
tyetrask
added
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
triage needed
This issue needs more specific labels
labels
Jun 25, 2024
Description
(Hello, this is my first issue in
swiftlang/swift
so I apologize in advance if I've put it somewhere incorrect or made mistakes/omissions in the report! @rauhul suggested creating this issue for review and tagging him and @kubamracek. Thank you for looking!)Description
Using a class that contains a struct (with certain properties) within a Playdate game built with Swift Embedded, the game crashes when that class instance is deallocated.
System Crash Report
(Pease let me know if there are other sections from the report I shouldinclude!)
Reproduction
(⚠️ EDIT June 25th, 1:10pm Pacific: Updated example to use
swift-playdate-examples
instead, as it removes a dependency on a different third-party library.)Unfortunately, I don't yet have an individual snippet of Swift code that reproduces this issue without involving a Playdate game. I've tried to make this happen outside of a game still using Swift Embedded but haven't found something that crashes yet. I'll keep working on that and post an update here if/once I have something.
(This, of course, suggests the issue might not be with Swift Embedded- I'm mentioning it in case it is, as the conditions that cause it (and those that 'prevent' it) are fairly odd and are almost completely using 'plain' Swift types. All that said, if this issue should be closed for that reason, I fully understand!)
reproduction-deinit-crash
branch: https://github.com/tyetrask/swift-playdate-examples/tree/reproduction-deinit-crash2.5.0
a.k.a latest) is installedExamples/MyGame
in XCode(Copying the contents of
Game.swift
from the branch here as well:)Expected behavior
The app/Playdate Simulator should not crash 😄.
Environment
Apple Swift version 6.0-dev (LLVM 57177aa1b91540b, Swift 8be6286)
Target: arm64-apple-macosx14.0
(
swift-DEVELOPMENT-SNAPSHOT-2024-06-13-a.xctoolchain
, latest as of posting this issue)Additional information
No response
The text was updated successfully, but these errors were encountered: