Post

Replies

Boosts

Views

Activity

Any way to keep a web extension alive to post messages to the page?
I am writing a midi polyfill, to bridge Core Midi with Safari. This, in itself, is not a problem. The problem is that the Web Extension will get suspended the moment it's no longer actively called. This means that no callbacks due to midi changes from core midi can be passed back to the web page. If I use a setInterval call in background.js, then this keeps the extension alive somewhat, but the setInterval self ping will get aborted eventually, making the Extension suspend itself. I know of a fairly contrived workaround using the container application over XPC, but I am hoping there is a way to keep the Web Extension alive - or at least keep a thread in the same process as the Web Extension alive. Or any such workaround. Setting background to "persistent": true does not seem to make any difference.
0
0
652
Dec ’23
How to get displayName actually used by Finder when using FileProvider API
I am developing a FileProvider extension which will be launched for one or more domains. In the case where I have two domains, say with displayNames "Foo" and "Bar", the finder will then show "MyExtension - Foo" and "MyExtension - Bar" respectively after registering them with addDomain. However, if I only have a single domain, let's say "Foo" – then I just see "MyExtension" rather than "MyExtension - Foo". Now ideally I'd like to be able to control the entire name, but barring that at least be able to show the displayName even with a single domain. How can I achieve that?
0
1
435
Sep ’23
Text rendering NSAttributedString appears broken for advanced rendering
In order to create a nice outline effect to bitmaps, I would take an NSAttributedString, use CoreText to render it to a bitmap, with something like: CGContextSaveGState(context); CGContextSetTextDrawingMode(context, kCGTextStroke); CGContextSetLineWidth(context, (CGFloat)width * 2); CGContextSetLineJoin(context, kCGLineJoinRound); drawAttributedString(AttributedString(attributedString), context, drawArea); CGContextRestoreGState(context); drawAttributedString(AttributedString(attributedString), context, drawArea); So basically drawing over the old. It's just that in iOS14 (I haven't checked iOS13, but iOS12 is ok) and BigSur (didn't check Catalina, Mojave was fine) I started getting very broken rendering. After trying a gazillion things, I noted that if I first created the NSAttributedString with one NSFont, then replaced that NSFont with the same NSFont but with a larger size, rendering would get messed up. BUT if I replaced it with an NSFont of the exact same size it was fine! Also, this only happened if I was switching colour inside of the NSAttributedString. With a single colour + outline it was fine. Printing out the attributes in the broken NSAttributedString (with replaced font) and the original (with the smaller font), the attributes were identical aside from the font sizes and the pointer addresses. Everything else printed out was identical. BUT the problem doesn't end there. Setting a gradient for a foreground colour completely stopped working as well. Looking at iOS12 again it works perfectly fine, iOS14 (and BigSur) it's just a single colour as if the feature had never been there. Here's the Mac OS code snippet: NSImage *image = [[NSImage alloc] initWithCGImage:ret size:NSMakeSize(1, CGFloat(round(height)))]; NSColor *createdColorGradient = [NSColor colorWithPatternImage:image]; [copy addAttribute:(NSString *)kCTForegroundColorAttributeName value:createdColorGradient range:NSMakeRange(0, [copy length])]; Since both AppKit and UIKit stopped working here I can only assume there's some change in CoreText. But how do I work around these problems? Perfecting text rendering is something I already spent a lot of time doing and this used to be rock solid code.
0
0
1.1k
Apr ’21