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

Wren + arm64 => wrong float properties #669

Closed
p0nce opened this issue Jun 30, 2022 · 20 comments
Closed

Wren + arm64 => wrong float properties #669

p0nce opened this issue Jun 30, 2022 · 20 comments
Labels
ARM Is related to ARM support (future Mac, Raspberry Pi). Bug Reproduced bug. Mac This issue is Mac-specific. Super hard Solving this needs major refactoring. Wren Related to scripting.

Comments

@p0nce
Copy link
Collaborator

p0nce commented Jun 30, 2022

Also reported by QA: Cubase 12.0.30 + macOS => crash

@p0nce
Copy link
Collaborator Author

p0nce commented Jun 30, 2022

nativeWindowResize gets called but _window is null

p0nce pushed a commit that referenced this issue Jun 30, 2022
@p0nce
Copy link
Collaborator Author

p0nce commented Jun 30, 2022

Now the question is: is this still crashing for Cubase 12.0.30 + macOS

@p0nce p0nce added the Bug Reproduced bug. label Jul 6, 2022
@p0nce
Copy link
Collaborator Author

p0nce commented Jul 6, 2022

Reproduced in Cubase Pro 12, before fix, crashes at instantiation while displaying a non-Wren-styled UI (or perhaps, partially styled)

  • Does the above fix help? => No
  • Same in VST2? No, no problem in VST2. (EDIT: makes sense, since VST2 are Rosetta on Cubase I think)

@p0nce
Copy link
Collaborator Author

p0nce commented Jul 6, 2022

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

@p0nce
Copy link
Collaborator Author

p0nce commented Jul 6, 2022

Mmmmm, bug is release-only (EDIT: no), memory-corruption.

  • Does Panagement 2.4 + VST3 fail in the same way => no
  • Disable Wren to see => no crash indeed ...

@p0nce p0nce changed the title Infinite loop in VST3PluginTestHost + VST3 + Windows Infinite loop in VST3PluginTestHost + VST3 + Windows / Now = infinite loop in Cubase Jul 6, 2022
@p0nce
Copy link
Collaborator Author

p0nce commented Jul 6, 2022

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

@p0nce
Copy link
Collaborator Author

p0nce commented Jul 6, 2022

Perhaps, quite simply, we never tested Wren on arm64

  • 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... :(

  • Test workaround of removing Wren in Distort => nope, same problem with the drive knob => EDIT, bad test, not sure

@p0nce p0nce changed the title Infinite loop in VST3PluginTestHost + VST3 + Windows / Now = infinite loop in Cubase Wren + Cubase + VST3 => crash script Jul 6, 2022
@p0nce p0nce added the Wren Related to scripting. label Jul 6, 2022
@p0nce
Copy link
Collaborator Author

p0nce commented Jul 6, 2022

Capture d’écran 2022-07-06 à 13 23 38
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.

  • Same in x86_64? => no, it works in x86_64

@p0nce
Copy link
Collaborator Author

p0nce commented Jul 6, 2022

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.

@p0nce p0nce changed the title Wren + Cubase + VST3 => crash script Wren + Cubase + VST3 => crash / Distort not drawn properly in arm64 Jul 6, 2022
@p0nce
Copy link
Collaborator Author

p0nce commented Jul 6, 2022

Distort's problem: knobRadiusPx is small. because knobRadius is set to zero
Every Wren float property is assigned zero, but not int properties

@p0nce p0nce changed the title Wren + Cubase + VST3 => crash / Distort not drawn properly in arm64 Wren + Cubase + VST3 + arm64 => crash / Distort not drawn properly in arm64 Jul 6, 2022
@p0nce
Copy link
Collaborator Author

p0nce commented Jul 6, 2022

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?

@p0nce p0nce changed the title Wren + Cubase + VST3 + arm64 => crash / Distort not drawn properly in arm64 Wren + arm64 => wrong float properties Jul 8, 2022
@p0nce p0nce added ARM Is related to ARM support (future Mac, Raspberry Pi). Mac This issue is Mac-specific. Super hard Solving this needs major refactoring. labels Aug 16, 2022
@p0nce
Copy link
Collaborator Author

p0nce commented Sep 29, 2022

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...

@p0nce
Copy link
Collaborator Author

p0nce commented Sep 29, 2022

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

@p0nce
Copy link
Collaborator Author

p0nce commented Sep 29, 2022

Numbers are parsed with strtod and strtod is locale dependent, would it be possible that in arm64 C runtime uses a different locale?

@p0nce
Copy link
Collaborator Author

p0nce commented Sep 29, 2022

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

@p0nce
Copy link
Collaborator Author

p0nce commented Sep 29, 2022

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.

@p0nce
Copy link
Collaborator Author

p0nce commented Sep 29, 2022

  • Does scanf perform better? => no, is the same. This is rather scary for the other string to number conversions.

@p0nce
Copy link
Collaborator Author

p0nce commented Sep 30, 2022

Need scanf and strtod replacement for parsing float without locale interaction => #711

@p0nce
Copy link
Collaborator Author

p0nce commented Oct 1, 2022

Should be okay now if you use Dplug v12.7.22+ and wrep-port v1.1.4+, just need to test that.

@p0nce
Copy link
Collaborator Author

p0nce commented Oct 1, 2022

Fixed.

@p0nce p0nce closed this as completed Oct 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ARM Is related to ARM support (future Mac, Raspberry Pi). Bug Reproduced bug. Mac This issue is Mac-specific. Super hard Solving this needs major refactoring. Wren Related to scripting.
Projects
None yet
Development

No branches or pull requests

1 participant