Closed p0nce closed 1 year ago
nativeWindowResize
gets called but _window
is null
Now the question is: is this still crashing for Cubase 12.0.30 + macOS
Reproduced in Cubase Pro 12, before fix, crashes at instantiation while displaying a non-Wren-styled UI (or perhaps, partially styled)
Log from Cubase
Application Specific Information:
Cubase 12(2030,0x30f79c000) malloc: Heap corruption detected, free list is damaged at 0x600002f099e0
*** Incorrect guard value: 7233174018435146591
abort() called
Thread 0:: Dispatch queue: com.apple.main-thread
0 QuartzCore 0x7ff81bb1e642 get_malloc_zone() + 0
1 QuartzCore 0x7ff81b9b8053 CA::Layer::setter(unsigned int, _CAValueType, void const*) + 291
2 QuartzCore 0x7ff81b9c11b9 -[CALayer setContentsCenter:] + 27
3 CoreUI 0x7ff81bd0ce19 -[CUIThemeFacet updateLayer:effects:] + 770
4 CoreUI 0x7ff81bd978cc CUICoreThemeRenderer::CreateOrUpdatePushButtonOrBevelButtonRoundLayer(CUIRenditionKey*, CUIDescriptor const*, CALayer**) + 370
5 CoreUI 0x7ff81bd0a79c CUICoreThemeRenderer::CreateOrUpdateLayer(CUIDescriptor const*, CALayer**) + 886
6 CoreUI 0x7ff81bd0a3a8 CUIRenderer::CreateOrUpdateLayer(__CFDictionary const*, CALayer**) + 200
7 AppKit 0x7ff816e55bce -[NSCompositeAppearance _callCoreUIWithBlock:options:requireBezelTintColor:] + 398
8 AppKit 0x7ff816e70395 -[NSAppearance _createOrUpdateLayer:options:] + 79
9 AppKit 0x7ff816f17bb7 _withOverlaidDictionary + 128
10 AppKit 0x7ff81734e352 -[NSWidgetView _updateWidgetLayers] + 219
11 AppKit 0x7ff816f187fb -[NSWidgetView layout] + 17
12 AppKit 0x7ff816ea2b8f _NSViewLayout + 564
13 AppKit 0x7ff816ea2661 -[NSView _layoutSubtreeWithOldSize:] + 352
14 AppKit 0x7ff816ea27bc -[NSView _layoutSubtreeWithOldSize:] + 699
15 AppKit 0x7ff816ea27bc -[NSView _layoutSubtreeWithOldSize:] + 699
Mmmmm, bug is release-only (EDIT: no), memory-corruption.
Repro script:
dplug-build -a all -c VST3-FULL --installer -b release-debug
open builds/XXX-FULL-1.0.0.pkg
lldb -- /Applications/Cubase\ 12.app
Perhaps, quite simply, we never tested Wren on arm64
[x] reproduce with Distort => OK, central knob not positioned in VST3 + Cubase, it's working in REAPER Rosetta though
Note: a workaround would probably be to not use Wren and use classic reflow
... :(
[x] Test workaround of removing Wren in Distort => nope, same problem with the drive knob => EDIT, bad test, not sure
Perhaps another bug, but probably the same Knob correctly positioned, but oddly not drawn properly. Also in debug. printf doesn't work unfortunately, but lldb and running non-notarized builds now work. Sounds like a graphic primitive not working.
A matrix for testing if the center knob of Distort is properly drawn:
Logic + arm64 + AU => yes
Logic + x86_64 (Rosetta) + AU => yes
REAPER + x86_64 (Rosetta) + VST3 => yes
Cubase + arm64 + VST3 => no
Cubase + arm64 + VST2 => no
Cubase + x86_64 (Rosetta) + VST3 => yes
Cubase + x86_64 (Rosetta) + VST2 => yes
FLStudio + arm64 + VST2 => no
FLStudio + x86_64 (Rosetta) + VST2 => yes
So yeah apart from the Logic mystery the Distort bug seems related to arm64 and aaSoftDisc
.
Distort's problem: knobRadiusPx is small. because knobRadius is set to zero Every Wren float property is assigned zero, but not int properties
Wren instructions trace
131: 0004 CONSTANT 0 '1'
(fiber 0x600006a3c460) [closure 0x6000011433f0] | [class Plugin 0x6000025df980] | [class Plugin 0x6000025df980] | 620 | 330 | 1 | [class Plugin 0x6000025df980] | [instance 0x600001143840] | [instance 0x600001143870] | [instance 0x6000011438a0] | [instance 0x6000011438a0] | 0 | [foreign 0x6000011438d0] | 1 |
131: 0007 CONSTANT 1 '0'
(fiber 0x600006a3c460) [closure 0x6000011433f0] | [class Plugin 0x6000025df980] | [class Plugin 0x6000025df980] | 620 | 330 | 1 | [class Plugin 0x6000025df980] | [instance 0x600001143840] | [instance 0x600001143870] | [instance 0x6000011438a0] | [instance 0x6000011438a0] | 0 | [foreign 0x6000011438d0] | 1 | 0 |
131: 0010 LOAD_LOCAL_1
(fiber 0x600006a3c460) [closure 0x6000011433f0] | [class Plugin 0x6000025df980] | [class Plugin 0x6000025df980] | 620 | 330 | 1 | [class Plugin 0x6000025df980] | [instance 0x600001143840] | [instance 0x600001143870] | [instance 0x6000011438a0] | [instance 0x6000011438a0] | 0 | [foreign 0x6000011438d0] | 1 | 0 | 0 |
131: 0011 CALL_3 210 'setProp_(_,_,_)'
assign property knobRadius
* float value 0,000000
The Wren properties:
knobRadius=(x){
e.setProp_(1,0,x)
}
The styling code:
driveKnob.knobRadius = 0.65
so... why would the local hold zero instead of 0.65?
The wren line:
($"_driveKnob").knobRadius(0.65) // does nothing yet, but an UIKnob is returned
.numLEDs(15)
.LEDRadiusMin(0.06)
.LEDRadiusMax(0.06)
compiles to instructions:
36: 0208 CONSTANT 9 '_driveKnob'
0211 CALL_0 160 '$'
0214 CONSTANT 8 '0'
0217 CALL_1 190 'knobRadius(_)'
37: 0220 CONSTANT 16 '15'
0223 CALL_1 191 'numLEDs(_)'
38: 0226 CONSTANT 8 '0'
0229 CALL_1 192 'LEDRadiusMin(_)'
39: 0232 CONSTANT 8 '0'
0235 CALL_1 193 'LEDRadiusMax(_)'
which is wrong since the literals just get truncated after the dot...
In Rosetta, correctly compiled to:
36: 0208 CONSTANT 9 '_driveKnob'
0211 CALL_0 160 '$'
0214 CONSTANT 16 '0.65'
0217 CALL_1 190 'knobRadius(_)'
37: 0220 CONSTANT 17 '15'
0223 CALL_1 191 'numLEDs(_)'
38: 0226 CONSTANT 18 '0.06'
0229 CALL_1 192 'LEDRadiusMin(_)'
39: 0232 CONSTANT 18 '0.06'
0235 CALL_1 193 'LEDRadiusMax(_)'
0238 POP
Numbers are parsed with strtod and strtod is locale dependent, would it be possible that in arm64 C runtime uses a different locale?
strtod("0.65) // does nothing yet, but an UIKnob is returned
.numLEDs(15)
.LEDRadiusMin(0.06)
.LEDRadiusMax(0.06)
}
static reflow() {
var W = UI.width
var H = UI.height
var S = W / UI.defaultWidth
($"_imageKnob").position = Rectangle.new(517, 176, 46, 46).scaleByFactor(S)
($"_inputSlider").position = Rectangle.new(190, 132, 30, 130).scaleByFactor(S)
($"_outputSlider").position = Rectangle.new(410, 132, 30, 130).scaleByFactor(S)
($"_onOffSwitch").position = Rectangle.new(90, 177, 30, 40).scaleByFactor(S)
($"_driveKnob").position = Rectangle.new(250, 140, 120, 120).scaleByFactor(S)
($"_inputLevel").position = Rectangle.new(150, 132, 30, 130).scaleByFactor(S)
($"_outputLevel").position = Rectangle.new(450, 132, 30, 130).scaleByFactor(S)
($"_colorCorrection").position = Rectangle.new(0, 0, W, H)
($"_resizer").position = Rectangle.new(W-30, H-30, 30, 30)
setupEverything()
}
}")
parsed number literal = 0
FLStudio and Cubase on arm64 set the C locale to french???
0.65 is parsed = 0
0,65 is parsed = 0,65
and Wren uses strtod
which means many other arm64 things will break. Shame.
Need scanf and strtod replacement for parsing float without locale interaction => #711
Should be okay now if you use Dplug v12.7.22+ and wrep-port v1.1.4+, just need to test that.
Fixed.
Also reported by QA: Cubase 12.0.30 + macOS => crash