mrkite / TerraFirma

Mapping for Terraria
http://seancode.com/terrafirma
BSD 2-Clause "Simplified" License
278 stars 61 forks source link

Launch crash on MacOS #114

Closed MrLavender closed 3 years ago

MrLavender commented 3 years ago

Terrafirma crashes when launched on MacOS since the Steam Client update on 7 Dec. The cause is Steam config parsing so I guess something changed there.

This can be proved by renaming the config file (~/Library/Application Support/Steam/config/config.vdf) so Terrafirma can't find it, then it launches and works perfectly.

Relevant portion of crash report;

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   com.seancode.terrafirma         0x000000010eec11b0 QString::operator=(QString const&) + 16
1   com.seancode.terrafirma         0x000000010e729d23 SteamConfig::Element::Element(QList<QString>*) + 1139
2   com.seancode.terrafirma         0x000000010e729528 SteamConfig::parse(QString const&) + 200
3   com.seancode.terrafirma         0x000000010e7292ba SteamConfig::SteamConfig() + 618
4   com.seancode.terrafirma         0x000000010e73e8a1 SettingsDialog::SettingsDialog(QWidget*) + 145
5   com.seancode.terrafirma         0x000000010e713715 MainWindow::MainWindow(QWidget*) + 613
6   com.seancode.terrafirma         0x000000010e70f49e main + 718
7   libdyld.dylib                   0x00007fff7f18a3d5 start + 1
mrkite commented 3 years ago

Thanks, I'll update Steam and see if I can replicate.

MrLavender commented 3 years ago

Had some time on my hands and looked into this further. It's a strange one, so I'm not surprised if you couldn't replicate it.

SHORT VERSION

It's possible for config.vdf to contain values with line breaks in them, this crashes the parser. E.g. saving this as config.vdf will crash it;

"InstallConfigStore"
{
  "Name" "Value1
Value2"
}

This commit fixes the crash and all seems ok. I haven't submitted a pull request because I didn't spend any time checking it for correctness beyond running the app and opening a world.

LONG VERSION

I have a custom HID game controller which isn't recognized by some SDL2 apps, most notably DuckStation. To fix this I created a controller mapping and set the SDL_GAMECONTROLLERCONFIG environment variable to that mapping. DuckStation now sees the controller.

The Steam client also looks at this environment variable, and if present uses it to set the "SDL_GamepadBind" property in config.vdf. E.g.

  "SDL_GamepadBind"   "03000000eb0300004320000001000000,PSXtoHID,platform:Mac OS X,a:b0,b:b1,x:b2,y:b3,back:b8,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:b12,dpdown:b13,dpleft:b14,dpright:b15,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,"

The problem is that there appears to be a bug now where the Steam client will keep adding the same mapping every time it is launched, with line break seperators. So my config contains something like this (note opening " only on first line and closing " on last line).

  "SDL_GamepadBind"   "03000000eb0300004320000001000000,PSXtoHID,platform:Mac OS X,a:b0,b:b1,x:b2,y:b3,back:b8,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:b12,dpdown:b13,dpleft:b14,dpright:b15,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,
03000000eb0300004320000001000000,PSXtoHID,platform:Mac OS X,a:b0,b:b1,x:b2,y:b3,back:b8,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:b12,dpdown:b13,dpleft:b14,dpright:b15,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,
03000000eb0300004320000001000000,PSXtoHID,platform:Mac OS X,a:b0,b:b1,x:b2,y:b3,back:b8,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:b12,dpdown:b13,dpleft:b14,dpright:b15,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,
03000000eb0300004320000001000000,PSXtoHID,platform:Mac OS X,a:b0,b:b1,x:b2,y:b3,back:b8,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:b12,dpdown:b13,dpleft:b14,dpright:b15,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,
03000000eb0300004320000001000000,PSXtoHID,platform:Mac OS X,a:b0,b:b1,x:b2,y:b3,back:b8,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:b12,dpdown:b13,dpleft:b14,dpright:b15,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,
03000000eb0300004320000001000000,PSXtoHID,platform:Mac OS X,a:b0,b:b1,x:b2,y:b3,back:b8,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:b12,dpdown:b13,dpleft:b14,dpright:b15,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,"
mrkite commented 3 years ago

Thanks good catch. I'll release an update today.