Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
There's nothing wrong with the code you posted, other than being so heavily excerpted that nobody could possibly help you with your problem.

You should see what it does in the debugger; it's possible run it on the device while still connected to the debugger.

Adbot
ADBOT LOVES YOU

Data Graham
Dec 28, 2009

📈📊🍪😋



Well, if I do that I get a symbol dump, but I'm not sure how to read it. The last thing in the stack trace before each crash is TTSPlaybackSetUseVoiceBooster.

I'm happy to delve into this to whatever degree I have to; if that means building an isolated case project I can.



E:

code:
TTSSpeechBundle`TTSPlaybackSetUseVoiceBooster:
    0x1024d4b40 <+0>:   stp    x20, x19, [sp, #-32]!
    0x1024d4b44 <+4>:   stp    x29, x30, [sp, #16]
    0x1024d4b48 <+8>:   add    x29, sp, #16
    0x1024d4b4c <+12>:  sub    sp, sp, #16
    0x1024d4b50 <+16>:  mov    x19, x1
    0x1024d4b54 <+20>:  mov    x20, x0
    0x1024d4b58 <+24>:  adrp   x8, 644
    0x1024d4b5c <+28>:  ldr    x8, [x8, #16]
    0x1024d4b60 <+32>:  ldrb   w8, [x8]
    0x1024d4b64 <+36>:  tbz    w8, #0, 0x1024d4b9c       ; <+92>
    0x1024d4b68 <+40>:  adrp   x8, 509
    0x1024d4b6c <+44>:  add    x8, x8, #1780
    0x1024d4b70 <+48>:  adrp   x9, 509
    0x1024d4b74 <+52>:  add    x9, x9, #1775
    0x1024d4b78 <+56>:  cmp    w19, #0
    0x1024d4b7c <+60>:  csel   x8, x9, x8, ne
    0x1024d4b80 <+64>:  adrp   x9, 509
    0x1024d4b84 <+68>:  add    x9, x9, #1745
    0x1024d4b88 <+72>:  stp    x9, x8, [sp]
    0x1024d4b8c <+76>:  adrp   x1, 509
    0x1024d4b90 <+80>:  add    x1, x1, #1728
    0x1024d4b94 <+84>:  orr    w0, wzr, #0x7
    0x1024d4b98 <+88>:  bl     0x1026d0650               ; symbol stub for: __TTSLog
->  0x1024d4b9c <+92>:  strb   w19, [x20, #153]
    0x1024d4ba0 <+96>:  sub    sp, x29, #16
    0x1024d4ba4 <+100>: ldp    x29, x30, [sp, #16]
    0x1024d4ba8 <+104>: ldp    x20, x19, [sp], #32
    0x1024d4bac <+108>: ret    

Data Graham fucked around with this message at 17:03 on Dec 28, 2015

Data Graham
Dec 28, 2009

📈📊🍪😋



I thought it might be that I need to link AVFoundation and/or CoreAudio with the keyboard extension at compile time, but no dice. And I know at least it's not about the declaration options since it does the same thing if I init the synthesizer inline in the speakMessage function.

Data Graham
Dec 28, 2009

📈📊🍪😋



I made a super simple demo app that has this behavior.

Doctor w-rw-rw-
Jun 24, 2008
Anyone have good advice on how to get into kernel programming? I've grokked a little bit of Mach IPC, but want to learn the other deep stuff that makes xpc (and others) tick.

Doc Block
Apr 15, 2003
Fun Shoe

Doctor w-rw-rw- posted:

Anyone have good advice on how to get into kernel programming? I've grokked a little bit of Mach IPC, but want to learn the other deep stuff that makes xpc (and others) tick.

Step 1: grow a very long beard

Data Graham
Dec 28, 2009

📈📊🍪😋



Data Graham posted:

I made a super simple demo app that has this behavior.

Status update, I've punted and now I'm just having it play a prerecorded audio clip. I really feel like this should not be necessary though :sigh:

Doc Block
Apr 15, 2003
Fun Shoe
I made a sample app and speech synthesis works fine v:shobon:v

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Data Graham posted:

Well, if I do that I get a symbol dump, but I'm not sure how to read it. The last thing in the stack trace before each crash is TTSPlaybackSetUseVoiceBooster.

I'm happy to delve into this to whatever degree I have to; if that means building an isolated case project I can.



E:

code:

TTSSpeechBundle`TTSPlaybackSetUseVoiceBooster:
    0x1024d4b40 <+0>:   stp    x20, x19, [sp, #-32]!
    0x1024d4b44 <+4>:   stp    x29, x30, [sp, #16]
    0x1024d4b48 <+8>:   add    x29, sp, #16
    0x1024d4b4c <+12>:  sub    sp, sp, #16
    0x1024d4b50 <+16>:  mov    x19, x1
    0x1024d4b54 <+20>:  mov    x20, x0
    0x1024d4b58 <+24>:  adrp   x8, 644
    0x1024d4b5c <+28>:  ldr    x8, [x8, #16]
    0x1024d4b60 <+32>:  ldrb   w8, [x8]
    0x1024d4b64 <+36>:  tbz    w8, #0, 0x1024d4b9c       ; <+92>
    0x1024d4b68 <+40>:  adrp   x8, 509
    0x1024d4b6c <+44>:  add    x8, x8, #1780
    0x1024d4b70 <+48>:  adrp   x9, 509
    0x1024d4b74 <+52>:  add    x9, x9, #1775
    0x1024d4b78 <+56>:  cmp    w19, #0
    0x1024d4b7c <+60>:  csel   x8, x9, x8, ne
    0x1024d4b80 <+64>:  adrp   x9, 509
    0x1024d4b84 <+68>:  add    x9, x9, #1745
    0x1024d4b88 <+72>:  stp    x9, x8, [sp]
    0x1024d4b8c <+76>:  adrp   x1, 509
    0x1024d4b90 <+80>:  add    x1, x1, #1728
    0x1024d4b94 <+84>:  orr    w0, wzr, #0x7
    0x1024d4b98 <+88>:  bl     0x1026d0650               ; symbol stub for: __TTSLog
->  0x1024d4b9c <+92>:  strb   w19, [x20, #153]
    0x1024d4ba0 <+96>:  sub    sp, x29, #16
    0x1024d4ba4 <+100>: ldp    x29, x30, [sp, #16]
    0x1024d4ba8 <+104>: ldp    x20, x19, [sp], #32
    0x1024d4bac <+108>: ret    

The immediate cause of the crash is that this function has been passed a null pointer as its first argument, which apparently isn't allowed. I assume you're not calling it directly, but maybe you can figure out from the backtrace why that's happening. Maybe you're doing something at the wrong point during initialization?

Data Graham
Dec 28, 2009

📈📊🍪😋



Doc Block posted:

I made a sample app and speech synthesis works fine v:shobon:v

Thanks for this—but the main thing is speech synthesis from within a keyboard extension. Speaking utterances from the containing app works fine. Sorry if I wasn't clear.

Data Graham
Dec 28, 2009

📈📊🍪😋



rjmccall posted:

The immediate cause of the crash is that this function has been passed a null pointer as its first argument, which apparently isn't allowed. I assume you're not calling it directly, but maybe you can figure out from the backtrace why that's happening. Maybe you're doing something at the wrong point during initialization?

I have to imagine so. I can't figure why it would work in the simulator but not on the device, though. Is viewDidLoad the right place to be alloc'ing my synthesizer?

I put my project here: https://github.com/bctiemann/kb-speech-test

Doc Block
Apr 15, 2003
Fun Shoe
I added a keyboard extension to my test app, and yeah, it seems that speech synthesis doesn't work from inside keyboard extensions.

Doctor w-rw-rw-
Jun 24, 2008

Data Graham posted:

I have to imagine so. I can't figure why it would work in the simulator but not on the device, though. Is viewDidLoad the right place to be alloc'ing my synthesizer?

I put my project here: https://github.com/bctiemann/kb-speech-test

That doesn't crash for me, but I did get this:

quote:

2015-12-28 19:49:12.458 KB Test Keyboard[3600:989240] __27-[_UIRemoteKeyboards proxy]_block_invoke Failed to access remote service: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.UIKit.KeyboardManagement.hosted was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.UIKit.KeyboardManagement.hosted was invalidated.}
2015-12-28 19:49:12.459 KB Test Keyboard[3600:989240] XPC unexpectedly invalidated
2015-12-28 19:49:13.369 KB Test Keyboard[3600:989173] 19:49:13.368 ERROR: [0x1a135d000] 124: AudioSessionClient: Couldn't connect to com.apple.audio.AudioSession

E: Yep. The docs suggest you don't get access to the audio session directly:

Text Programming Guide for iOS/Playing Input Clicks posted:

The system automatically manages the audio session for custom input clicks, including audio ducking as needed. (For information on audio sessions, see Audio Session Programming Guide.)
Well, I may have misread this as technically this excerpt applies to accessory views. But it's likely to also apply given the error of not being able to connect to the audio session from within the keyboard.

As for why:

Audio Session Programming Guide/Running Your App in the Simulator posted:

When you add audio session support to your app, you can run your app in the Simulator or on a device. However, the Simulator does not simulate audio session behavior and does not have access to the hardware features of a device.

Also, the error when 'Speak Message' is pressed:

quote:

2015-12-28 20:05:19.775 KB Test Keyboard[3950:994816] 20:05:19.775 ERROR: [0x16e2d3000] 645: Couldn't connect to com.apple.audio.AudioQueueServer; AudioQueue will not be usable

Doctor w-rw-rw- fucked around with this message at 05:06 on Dec 29, 2015

Data Graham
Dec 28, 2009

📈📊🍪😋



Where do you see that console output? I connect to the keyboard process in Debug, but I never get any console logging for the keyboard target, only for the container app.

Anyway, thanks for chasing that down; fooey.

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
I suspect the constrained environment of a keyboard extension may not be allowed to access audio services in the way you want.

Are the APIs in question marked as extension-safe? And if they are extension-safe APIs, does your extension have any required entitlements?

Also, an "is it plugged in" question: Are you certain your extension links the frameworks you need?

Doc Block
Apr 15, 2003
Fun Shoe
It makes sense that keyboard extensions can't play audio themselves, with the OS handling keyboard clicks etc.

A user having keyclicks turned off is a pretty clear indication they want the keyboard to be silent, and even if they don't have them disabled they almost certainly don't want their music/podcast/whatever getting cut out so the keyboard can play cute little sounds or whatever while they type out a quick text message.

Doc Block fucked around with this message at 05:55 on Dec 29, 2015

Doctor w-rw-rw-
Jun 24, 2008

Data Graham posted:

Where do you see that console output? I connect to the keyboard process in Debug, but I never get any console logging for the keyboard target, only for the container app.

Anyway, thanks for chasing that down; fooey.
I'm launching the KB Test Keyboard extension against the test app on a 9.0 device. Maybe 9.2 has a crash?

Data Graham
Dec 28, 2009

📈📊🍪😋



Doctor w-rw-rw- posted:

I'm launching the KB Test Keyboard extension against the test app on a 9.0 device. Maybe 9.2 has a crash?

Nah, it's the same for me back to 8.4. Anyway, no, what I meant was, how do you actually get any output to show up? I don't get any NSLog messages that I put in the keyboard extension, regardless of whether I've selected the keyboard target in the console log viewer, or even if I only attach to the keyboard process and not the container app process. It's the same on the simulator vs. the device too. Is there some trick to this?

Doc Block
Apr 15, 2003
Fun Shoe
Select the keyboard scheme instead of your app's scheme, then build & run that. It'll ask you which app to run your extension in, and once you pick one you're off and running and any logged messages should show up.

Doctor w-rw-rw-
Jun 24, 2008

Data Graham posted:

Is there some trick to this?
None whatsoever. If it's not working for you then something about your stuff is broken.

Data Graham
Dec 28, 2009

📈📊🍪😋



Doc Block posted:

Select the keyboard scheme instead of your app's scheme, then build & run that. It'll ask you which app to run your extension in, and once you pick one you're off and running and any logged messages should show up.

Huh. That was the trick. Thanks!

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice
Speaking of random nonsense that breaks everything: If you have a Swift file with multiple XCTestCase subclasses then Xcode will steadfastly refuse to enable the record UI test button. Yeah.

lord funk
Feb 16, 2004

Plowing my way through adopting size classes and I seriously love laying things out manually. I just like setting precise margins, sizes, and offsets, and seeing everything fall into place.

It also reaffirms my dislike of Storyboard layout. Everything I've ever laid out in IB I've ended up redoing in code and been much happier.

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

lord funk posted:

Plowing my way through adopting size classes and I seriously love laying things out manually. I just like setting precise margins, sizes, and offsets, and seeing everything fall into place.

It also reaffirms my dislike of Storyboard layout. Everything I've ever laid out in IB I've ended up redoing in code and been much happier.

Drop iOS 8- and adopt UIStackView. It's what Autolayout v1 should have been, with the rest of this Autolayout stuff lurking in the shadows for truly advanced cases.

lord funk
Feb 16, 2004

Ender.uNF posted:

Drop iOS 8- and adopt UIStackView. It's what Autolayout v1 should have been, with the rest of this Autolayout stuff lurking in the shadows for truly advanced cases.

Nope. Not getting burned by any more Apple layout stuff. I don't like all the opaque work that goes on you don't get to see. For example:

UIStackView Class Reference posted:

Note: Baseline alignment only works on views whose height matches their intrinsic content size’s height. If the view is stretched or compressed, the baseline appears in the wrong location.

Good to know! And I'm sure there are a dozen other little niggles that you'll only find out when you're knee-deep in a complicated layout and you can't figure out why your stack keeps shifting down by 30 points and ahhhhhHHHHHHHH.

This is clearly a YMMV, but I'm just so much happier knowing everything about why my views are where they are.

Doctor w-rw-rw-
Jun 24, 2008
layoutSubviews is love, layoutSubviews is life

(or frankly anything that allows you to control the execution of measure+layout phases is decent)

chimz
Jul 27, 2005

Science isn't about why, it's about why not.

Doctor w-rw-rw- posted:

Anyone have good advice on how to get into kernel programming? I've grokked a little bit of Mach IPC, but want to learn the other deep stuff that makes xpc (and others) tick.

Is there some specific technology you're exited about? There's an almost infinite depth of complexity when diving into operating systems, it helps to have some small piece to pick apart.
XPC is built on top of Mach IPC and libdispatch - there's no extra kernel magic going on.
However, XPC is going to be more difficult for you to investigate because it isn't open source.

Here's some books on the lower layers of OS X: this one is pretty old school (10.4) but covers a lot of in-depth kernel stuff:
http://osxbook.com

and this one is supposedly more up to date, but I haven't read it yet:
http://newosxbook.com

Doctor w-rw-rw-
Jun 24, 2008
Yep, I own both. Maybe looking at NextBSD's implementation of XPC will be educational.

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Doctor w-rw-rw- posted:

Yep, I own both. Maybe looking at NextBSD's implementation of XPC will be educational.

One way to get into it would be to dig into the implementation and try to fix some bugs or implement some features in their APIs in general (beyond just XPC too). A bonus would be the potential mentoring you could get from others hacking on NextBSD, they're top-tier OS hackers.

Another way to get your feet wet would be to help with the bring-up of the Swift Core Libraries version of libdispatch and Foundation on non-OS X platforms. A lot of that stuff can use OS-level functionality, whether that's in-kernel or a layer above it.

For one example, NSTask is really best implemented atop posix_spawn but either it may not be supported or not have all the needed features on Linux, FreeBSD, NetBSD, etc. It's not necessarily just kernel development , it's systems development.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
Here is my two word review of UIStackView:

It's good.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
I feel so stupid saying that to anyone who's ever used, like, any other UI framework ever. Yet I agree completely.

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer

pokeyman posted:

I feel so stupid saying that to anyone who's ever used, like, any other UI framework ever. Yet I agree completely.

No, don't fight it. I'm increasingly convinced that 90%+ precent of UI code is expressible as a FlexBox/UIStackView, and we'd all be better for it if everyone just collectively came to that conclusion.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
I'd been dreading redoing a custom table cell I had because I'd changed some underlying mechanics, and it turned out to be basically trivial to just make it a big vertical UIStackView with smaller ones when I needed to line up a couple elements horizontally.

It makes basic property/edit pages take the amount of time/effort I expect such things to take for how much thought needs to go into them. I can lay out things that go like label-text box-label-textbox-button without a million trips to the constraint edit panes getting them to line up properly.

I don't consider myself a good designer by any means, and maybe a Real Designer would want to do much more custom layout than I'm doing. But when I just want to whack together the face to a bunch of backend code I wrote, add a single element to a settings page or whatever, I can now do that without expecting it to be an hour+ part of implementing the feature.

It's the sleeper best feature of iOS 9.

Built 4 Cuban Linux
Jul 15, 2007

i own america
I was updating my app for iOS 9 and replaced ~200 lines of custom layout code with 3 lines of stack view stuff. Stack view is great.

Doh004
Apr 22, 2007

Mmmmm Donuts...
A buddy of mine has had success using this drop in replacement for the UIStackView in order to still support iOS8: https://github.com/tomvanzummeren/TZStackView

I'm thinking about trying it out soon because :drat:

kode54
Nov 26, 2007

aka kuroshi
Fun Shoe

Dessert Rose posted:

Here is my two word review of UIStackView:

It's good.

I'd love to recommend that to my fellow developer, in case he ever decides that he prefers easy coding. But for now, he insists on supporting all manner of ancient hardware he happens to have on hand.

stuffed crust punk
Oct 8, 2004

by LITERALLY AN ADMIN

kuroshi posted:

I'd love to recommend that to my fellow developer, in case he ever decides that he prefers easy coding. But for now, he insists on supporting all manner of ancient hardware he happens to have on hand.

Such is the life of supporting 2-years-back devices

99% chance he has to do so biz-wise

Doctor w-rw-rw-
Jun 24, 2008

kuroshi posted:

I'd love to recommend that to my fellow developer, in case he ever decides that he prefers easy coding. But for now, he insists on supporting all manner of ancient hardware he happens to have on hand.

Well, if you're not using Interface Builder I don't imagine it would be too hard to write your own stacking view. This was certainly possible back in ~2013, in the iOS 5 days.

Doh004
Apr 22, 2007

Mmmmm Donuts...

kuroshi posted:

I'd love to recommend that to my fellow developer, in case he ever decides that he prefers easy coding. But for now, he insists on supporting all manner of ancient hardware he happens to have on hand.

Didn't read the post above, did you?

Adbot
ADBOT LOVES YOU

kode54
Nov 26, 2007

aka kuroshi
Fun Shoe

Doh004 posted:

Didn't read the post above, did you?

He still intends to support iOS 6.1. For personal reasons. He is in charge of the project, after all. The business reason is that he actually happens to own several devices that were EOLed at iOS 6.1, and by gum, he'll make sure his software runs perfectly on them as well as any new device.

The software is the mobile version of foobar2000, which is being launched for iOS, Android, Windows Phone 8, and Windows Universal for Windows 10 (and 10 Phone).

So far, it's interesting benchmarking things on my various devices, since I have to limit various quad core Android devices to only two benchmark threads to compare per-core performance to the iOS devices I have, since they're all dual core devices. So far, the iOS devices stomp all over everything else.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply