AUv3 MacOS Instrument, auval failure "Bad Max Frames - Render should fail" - objective-c

This is the umpteenth time I've tried to create an AUv3 plugin, all with various amounts of success (no complete joy, ever :/ )
It works in the app, but auval fails with
Bad Max Frames - Render should fail
ERROR: AudioUnitRender should have returned an error for too many frames but returned noErr
Current OS: 10.13.5
XCode: 9.4
created an AUv3 MacOS Instrument by creating a Cocoa Objective C app
added an AudioUnit app extension
added a Cocoa framework
etc. Details supplied if needed. (I made notes about my steps since I've never completely succeeded previously.) It is essentially the same as the Demo MacOS AUv3 instrument but I started the project from scratch. The only swift code is in SimplePlayEngine.swift. The rest is Objective C, Objective C++, and straight-up C++.
The only web search hit I found on this problem is add arg to prepareInputBufferList but there are two problems with this link:
Applying the change doesn't fix my problem
The demo AUv3 instrument builds and passes auval validation on my system with no modification.
I don't know if this is related but I find that NO breakpoint I set in the audiounit or related files (BufferedAudioBus.hpp) is ever hit. Since the audiounit functions in the app I must assume that the code is getting executed but something about the way it was built is wrong. (NSLog messages don't get printed either ... ??? (yes I know that when realtime rendering, printing to the console is a bad idea)).
I diffed between my AU source and the demo AU and the only changes are name changes. The "Build Phases" are comparable.
I know this is a pretty non-specific question, but I've run out of ideas. Does anyone have any ideas where to look to resolve the "Bad Max Frames" auval failure?

Related

Google maps iOS SDK breaks when a certain library is linked into the application

Background
I am exploring using the Google Maps iOS SDK in an application that will also tightly depend on another statically linked C++ library. I have accomplished Google's prescribed Hello World program successfully with one caveat: using the -ObjC linker flag causes linker errors with my other library. To remedy this, I've been using the -force_load /path/to/GoogleMaps instead in order to only target the GoogleMaps framework, which seems to work well.
The Problem
When I reference certain (not all) classes inside the static library in custom C++ classes in my app (even if I don't instantiate those classes in the app itself) I repeatably see this strange runtime error:
ClientParametersRequest failed, 3 attempts remaining (0 vs 5). (null)
ClientParametersRequest failed, 2 attempts remaining (0 vs 5). (null)
ClientParametersRequest failed, 1 attempts remaining (0 vs 5). (null)
ClientParametersRequest failed, 0 attempts remaining (0 vs 5). (null)
The result in the app is that the pin and default off-white google background appear, but no maps are downloaded.
If I delete the app from the simulator or device and comment out the static library code and run the app, the maps load and everything works fine. Then, if I add those lines back in and run the app, I don't see these errors and the maps still load fine.
If I delete the app and leave those lines in for the firstrun of the app, I get these errors, but if I then comment out the library code and re-run it, the maps begin to load and all is well. Adding back in the library code does not cause the error messages/runtime issue to come back.
This leads me to believe that the error is occurring in some sort of initialization routine that is never subsequently called. I checked the files in the app sandbox and some are missing until the maps load properly, which makes me think this is correct.
I have access to the source for the static library but obviously don't have access to the GoogleMaps SDK. There does not appear to be any clear documentation about what this error means, especially in my case where (null) is the final piece.
A few final notes that may or may not be relevant:
C++ Language Dialect: C++11 [-std=c++11]
C++ Standard Library: libc++
Thanks in advance for any help!

Debugging interpreter in VM when changing vm primitives

Context
As a university project we want to change the the pharo vm to use an object-table and see what happens.
We use a pharo-vm clone from github and VMMaker. Building the VM works fine.
To get started we added a primitive that returns an incremented Integer:
InterpreterPrimitives>>primitiveIntegerIncrement
"increments an integer"
self pushInteger: self popInteger + 1 .
and modified StackInterpreter class>>initializePrimitiveTable accordingly
MaxPrimitiveIndex := 576.
"... and so on ..."
(575 primitiveFail)
(576 primitiveIntegerIncrement))
And it works.
Problem
When we make changes to the VM we want to test-run already in the SmalltalkImage so we do not need to compile and see it did not work.
Something like:
StackInterpreter test: '1 inc'
And then I can debug if the primitive is wrong or an error occurs. Of course there needs to be done much more but how can I achieve this?
What we tried
category VMMaker-InterpreterSimulation class StackInterpreterSimulator. Trying the code in the comments
DoIt
^ (StackInterpreterSimulator new openOn: Smalltalk imageName) test
errors:
displayForm := 'Display has not yet been installed' asDisplayText form.
the ByteString does not understand asDisplayText
(CogVMSimulator new openOn: Smalltalk imageName) test
(InterpreterSimulator new openOn: Smalltalk imageName) test
error:
PrimitiveFailed: primitive #basicNew: in Array class failed
I also found this screen cast but it only debugs the VM from outside using gbd: http://vimeo.com/22485382#
Our project is hosted here: http://smalltalkhub.com/#!/~kirstin/PharoObjectTable
Current Status
We started implementing an object table. The lookup of attributes can go throught the object table. Full object table support and no usage of direct pointes is very tricky since pointers are expected everywhere. So we use pointers into the object table to identify when a lookup should go through the OT. We also found all object creation primitives and add new objects to the table.
How long is your project and how many people are you ? To me what you try to do is quite some work. Do you have good knowledge about low level behavior ?
To answer your question, the main problem here is that the cog simulator is not maintained in the pharo vm fork. This is because no one in the pharo crew use the simulator. We only use external debugging from gdb. In fact the pharo folks work mostly on VM plugins, the core of the VM is mainly maintained and developed by Eliot Miranda which works on Squeak. Therefore we report to him when there's a bug in the VM core.
For your project you would have to split it in at least 2 steps:
step 1: make the object table work with the stack VM
step 2: make the JIT work with your object table
Note that for step 2 I would recommend not to change the way an object access its header, therefore having a VW-like object table where you have the fixed size header on the one in the the object table, and the fields of the objects (and maybe header extensions) in the heap.
So use the StackVMSimulator and build the StackVM first. When everything will work (including context), you can think about hacking the JIT. Recently Guillermo Polito ported the Stack VM to the build process (see PharoSVMBuilder instead of PharoVMBuilder), a guy reported problems with this builder but you could hack it a bit to make it work.
Now to make the simulator work on Pharo 2.0 (which is the Pharo version of the generator image you have), you have to open the monticello browser and merge from Eliot's branch the Cog package (repo MCHttpRepository location: 'http: //source. squeak. org/VMMaker'), but not the latest Cog, the one at around the same date as the current VMMaker package of pharo-vm because the latest Cog and VMMaker of Eliot's branch are not stable.
The alternative being to start from Eliot's build image and merge things from the pharo branch. Here are infos about how to build the squeak development image (http://www.mirandabanda.org/cogblog/build-image/).
Then Eliot gave me this script once:
| cos |
cos := CogVMSimulator newWithOptions: #(Cogit SistaStackToRegisterMappingCogit).
cos desiredNumStackPages: 8.
cos openOn: 'my/favourite.image'.
cos openAsMorph; toggleTranscript; halt; run
You don't need the SistaStackToRegisterMappingCogit option. I guess some similar script with the StackVMSimulator should work.
Lastly there are some documentation about the simulator but it is only for the CogSimulator (these documentations expects you already knows how the StackSimulator works, and just give you hints about how to use it with the JIT):
http://www.mirandabanda.org/cogblog/2008/12/12/simulate-out-of-the-bochs/
and in one of the video named "Cog VM (part x)", x being from 1 to 6, Eliot shows how he uses the simulator to disassemble x86, print the stack and inspect the heap.
Another tip, ask your questions on the pharo mailing list (pharo users or pharo dev), because here no one may notice your question (fortunately someone pointed me out your question this time).
And tell on the pharo mailing list if you managed to run the simulator in Pharo 2.0, some people (as me) are very interested in it. I was planning to do it at some point.
Good luck ! Nice project anyway.
The last time I tried to use the simulator is roughly a year ago, and I did not make it work.
However, there are a few patches, which I assume never got integrated that might be of help:
https://code.google.com/p/cog/issues/detail?id=106
https://code.google.com/p/cog/issues/detail?id=107
https://code.google.com/p/cog/issues/detail?id=108
Issue 107 includes a patch for your asDisplayText issue.

How to get crash/hangs reports for applications, daemons and OSX programatically?

I know there is a way to get crashes and hangs for all applications. These files are placed in "/Users/user/Library/Logs/DiagnosticReports". So I could get version, time and name of the app.
But how to get daemon/process crashes and hangs? I need to know which exactly daemon was crashed/hanged and time when it happened.
Also is there is a way to get some system(OSX) crash with the same info?
Also would be great to get some resource failures/warnings: out of memory or out of disk space.
I need to get it programatically.
On Windows we can do this using NotifyChangeEventLog () API. All these info we can gather using such method. Also it notifies if something happened.
For the daemons crash/hang report see the "/Library/Logs/DiagnosticReports" directory. According to this document you can also find there kernel panic reports (i.e. system crash).
Don't know about NotifyChangeEventLog-like API, but in situations like "out of memory" there will be an exception, so you just need to catch it. See Error Handling Programming Guide for details. Also take a look at Exception Programming Topics
Edit: for the information about Crash Reporter take a look at Chapter 5 of Levin's book "Mac OS X and iOS Internals: To the Apple's Core"
in 10.9 the activity monitor offers you two tools when you have a hang but no crash hence no crash report:
spindump - memory dump like crash report and
sys digs which produces a bundle of files

Hot Code Swapping in Xcode?

I am doing iOS game development using the cocos2d framework, and I tremendously envy the ability for Eclipse Java programmers to hot swap their code while they are debugging their application (i.e. change out variable values within a method and have the program live update as if you had a REPL without having to recompile).
This seems like something that would be absolutely tremendously helpful when it came to iOS development, where my development environment is (obviously) Xcode and the language I am programming in is Objective C. I have googled around but havent been able to find anything - so I thought I would ask the community.
Does anyone know if there a way to Hot Swap code in Xcode while programming in Objective C?
Thanks in advance
There is a great plugin which allow changing code in live, working APP. It is called InjectionPlugin.
As FAQ says:
How does it work? The Objective-C runtime allows you to load a new version of a class into an application using a bundle even if there is already an implementation linked into the application. Swizzling is used as the bundle is loaded to switch the existing class to use the methods of the new implementation. This can be done repeatedly and works for OSX and iOS applications and on iOS devices.
I made some small video which shows how to install and use this plugin
http://nomtek.com/developers/how-to-install-and-use-injection-plugin-for-xcode/
Hope it helps!
Not possible with the current tools.
Keep in mind that iOS applications are signed -- if you change a single byte you'd have resign the whole thing. One could imagine making it work using runtime's support for dynamically adding and removing methods. But that'd surely require adding some extra stuff to support it on the device, and that's something that malware could easily take advantage of. So it's probably not a feature you'll be likely to see anytime soon.
By the way, Xcode versions 1.x-3.x did have a "Fix and Continue" feature. You could edit as you were debugging, use the Fix and Continue command, and continue running the updated code. I believe it was removed at some point, perhaps due to some combination of: requiring that your project be configured to use "zero link" and perhaps some other things; being less than completely reliable; probably not supporting iOS; the switch to llvm; other changes in Xcode 4. Maybe it'll come back someday -- if you want it back, file a bug -- but again, I think supporting it on iOS would be a challenge.
If you're just talking about changing variable values then you can achieve that surreptitiously via lldb (or, presumably) gdb. Supposing you had:
- (void)uselessMethod
{
NSString *localString = #"I'm some local text";
NSLog(#"%#", localString);
}
And put a breakpoint on the NSLog, at that point you could ask lldb to evaluate a reassignment of localString as a means of performing it. E.g.
po localString = #"Hat"
If you then allow program execution to continue, you should find that the reassignment has stuck. Similarly you can call any method or perform any other sort of assignment.
I've just tested this against Xcode 4.3.2.
You can hot swap a variable value in Xcode by:
expression <variable> = <value>;.
By having a break point in the place where you wanna change the value and doing the command in Xcode console.
Example:
// Messages From Console
(lldb) expression graphFlag = #"X"; // Update variable value
(__NSCFConstantString *) $0 = 0x36f95718 #"X" // Xcode prints the updated value
(lldb) expression graphFlag; // Printing value through expression command
(__NSCFConstantString *) $1 = 0x36f95718 #"X" // Hot Swapped variable value

Ruby/Obj-C require command fails

I'm currently trying to port twurl, a Ruby client for the Twitter API, into a OS X command line application using MacRuby. My goal is to "tweet" a NSString, but this turned out harder than expected. At first I was using native cocoa libraries, but I ended up not exactly knowing what to do.
However, twurl is capeable of simply "tweeting" a string and should be called to tweet the string passed to it as argument.
I am aware that this is far away from a good solution, but after 7 days of trying to get any of the native Obj-C libraries to work, I'm really close to tears and this is my last chance of getting close to what I want. If anybody can show me a working command-line solution with native code, please do so. I'd really appreciate that.
However, my concrete problem is that, as soon as I run my project, I get the following error: /Users/User/Library/Developer/Xcode/DerivedData/projectname-.../Build/Products/Debug/project.app/Contents/Resources/rb_main.rb:11:in `': no such file to load -- oauth (LoadError)