I encountered a problem in my project. It's about tombstone. I found out that it takes a long time to recover, sometimes it can be as long as 5 minutes with no error occuring!
I have never had a problem like that, can anyone tell me why?
Thanks
finally, I found where the problem is the code blow, if i remove them, the app works well.
DeviceNetworkInformation.ResolveHostNameAsync(
new System.Net.DnsEndPoint("m.baidu.com", 80),
new NameResolutionCallback(handle =>
{
NetworkInterfaceInfo info = handle.NetworkInterface;
if (info != null)
{
networkType = GetNetType(info);
}
else
networkType = NetType.NONE;
}), null);
Related
I call readRecords on line 74 and the syntax is simple, but the program hangs at this line. The Students table exists, with 12 students, it was originally created with the createRecord on line
60. I've looked at the syntax for this line for tooooo long. What am I missing?
Also, is there a more elegant way to use this data outside of the readRecords code block? I'm copying it to arrays (no 2-dimensional arrays or structures in applab). I tried to create a global 'records' of some kind, without success. The App Lab project examples I learned from use the data within the readRecords code block, but not outside the block.
The project:
my project: https://studio.code.org/projects/applab/xEEOqp8zpOJ2g-YyCntajlhvh0crb2ysLvP1Pg5LCF8
The specific code:
onEvent("choosePeriodNext", "click", function() {
var chosenPeriod = getText("period2");
readRecords("Students", {}, function(records) {
numStudents = records.length;
if (numStudents>0) {
for (var i =0; i < numStudents; i++) {
console.log (records[i].goesBy);
goesBys[i] = records[i].goesBy;
pronounss[i] = records[i].pronouns;
periods[i] = records[i].period;
firsts[i] = records[i].first;
lasts[i] = records[i].last;
games[i] = records[i].game;
jobs[i] = records[i].job;
goodAts[i] = records[i].goodAt;
toKnows[i] = records[i].toKnow;
photos[i] = records[i].photo;
}
learnNames();
} else setScreen ("home");
});
});
Thank you for your help!
Carol
I answered my own question.
I found that this code worked in a collegue's browser, but not mine.
I cleared cache and cookies, then restarted my browser. Now it works.
Oh my.
EDIT:
I have heavily edited this question after making some significant new discoveries and the question not having any answers yet.
Historically/AFAIK, keeping your Mac awake while in closed-display mode and not meeting Apple's requirements, has only been possible with a kernel extension (kext), or a command run as root. Recently however, I have discovered that there must be another way. I could really use some help figuring out how to get this working for use in a (100% free, no IAP) sandboxed Mac App Store (MAS) compatible app.
I have confirmed that some other MAS apps are able to do this, and it looks like they might be writing YES to a key named clamshellSleepDisabled. Or perhaps there's some other trickery involved that causes the key value to be set to YES? I found the function in IOPMrootDomain.cpp:
void IOPMrootDomain::setDisableClamShellSleep( bool val )
{
if (gIOPMWorkLoop->inGate() == false) {
gIOPMWorkLoop->runAction(
OSMemberFunctionCast(IOWorkLoop::Action, this, &IOPMrootDomain::setDisableClamShellSleep),
(OSObject *)this,
(void *)val);
return;
}
else {
DLOG("setDisableClamShellSleep(%x)\n", (uint32_t) val);
if ( clamshellSleepDisabled != val )
{
clamshellSleepDisabled = val;
// If clamshellSleepDisabled is reset to 0, reevaluate if
// system need to go to sleep due to clamshell state
if ( !clamshellSleepDisabled && clamshellClosed)
handlePowerNotification(kLocalEvalClamshellCommand);
}
}
}
I'd like to give this a try and see if that's all it takes, but I don't really have any idea about how to go about calling this function. It's certainly not a part of the IOPMrootDomain documentation, and I can't seem to find any helpful example code for functions that are in the IOPMrootDomain documentation, such as setAggressiveness or setPMAssertionLevel. Here's some evidence of what's going on behind the scenes according to Console:
I've had a tiny bit of experience working with IOMProotDomain via adapting some of ControlPlane's source for another project, but I'm at a loss for how to get started on this. Any help would be greatly appreciated. Thank you!
EDIT:
With #pmdj's contribution/answer, this has been solved!
Full example project:
https://github.com/x74353/CDMManager
This ended up being surprisingly simple/straightforward:
1. Import header:
#import <IOKit/pwr_mgt/IOPMLib.h>
2. Add this function in your implementation file:
IOReturn RootDomain_SetDisableClamShellSleep (io_connect_t root_domain_connection, bool disable)
{
uint32_t num_outputs = 0;
uint32_t input_count = 1;
uint64_t input[input_count];
input[0] = (uint64_t) { disable ? 1 : 0 };
return IOConnectCallScalarMethod(root_domain_connection, kPMSetClamshellSleepState, input, input_count, NULL, &num_outputs);
}
3. Use the following to call the above function from somewhere else in your implementation:
io_connect_t connection = IO_OBJECT_NULL;
io_service_t pmRootDomain = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPMrootDomain"));
IOServiceOpen (pmRootDomain, current_task(), 0, &connection);
// 'enable' is a bool you should assign a YES or NO value to prior to making this call
RootDomain_SetDisableClamShellSleep(connection, enable);
IOServiceClose(connection);
I have no personal experience with the PM root domain, but I do have extensive experience with IOKit, so here goes:
You want IOPMrootDomain::setDisableClamShellSleep() to be called.
A code search for sites calling setDisableClamShellSleep() quickly reveals a location in RootDomainUserClient::externalMethod(), in the file iokit/Kernel/RootDomainUserClient.cpp. This is certainly promising, as externalMethod() is what gets called in response to user space programs calling the IOConnectCall*() family of functions.
Let's dig in:
IOReturn RootDomainUserClient::externalMethod(
uint32_t selector,
IOExternalMethodArguments * arguments,
IOExternalMethodDispatch * dispatch __unused,
OSObject * target __unused,
void * reference __unused )
{
IOReturn ret = kIOReturnBadArgument;
switch (selector)
{
…
…
…
case kPMSetClamshellSleepState:
fOwner->setDisableClamShellSleep(arguments->scalarInput[0] ? true : false);
ret = kIOReturnSuccess;
break;
…
So, to invoke setDisableClamShellSleep() you'll need to:
Open a user client connection to IOPMrootDomain. This looks straightforward, because:
Upon inspection, IOPMrootDomain has an IOUserClientClass property of RootDomainUserClient, so IOServiceOpen() from user space will by default create an RootDomainUserClient instance.
IOPMrootDomain does not override the newUserClient member function, so there are no access controls there.
RootDomainUserClient::initWithTask() does not appear to place any restrictions (e.g. root user, code signing) on the connecting user space process.
So it should simply be a case of running this code in your program:
io_connect_t connection = IO_OBJECT_NULL;
IOReturn ret = IOServiceOpen(
root_domain_service,
current_task(),
0, // user client type, ignored
&connection);
Call the appropriate external method.
From the code excerpt earlier on, we know that the selector must be kPMSetClamshellSleepState.
arguments->scalarInput[0] being zero will call setDisableClamShellSleep(false), while a nonzero value will call setDisableClamShellSleep(true).
This amounts to:
IOReturn RootDomain_SetDisableClamShellSleep(io_connect_t root_domain_connection, bool disable)
{
uint32_t num_outputs = 0;
uint64_t inputs[] = { disable ? 1 : 0 };
return IOConnectCallScalarMethod(
root_domain_connection, kPMSetClamshellSleepState,
&inputs, 1, // 1 = length of array 'inputs'
NULL, &num_outputs);
}
When you're done with your io_connect_t handle, don't forget to IOServiceClose() it.
This should let you toggle clamshell sleep on or off. Note that there does not appear to be any provision for automatically resetting the value to its original state, so if your program crashes or exits without cleaning up after itself, whatever state was last set will remain. This might not be great from a user experience perspective, so perhaps try to defend against it somehow, for example in a crash handler.
IOCreatePlugInInterfaceForService failed w/ kIOReturnNoResources/0xe00002be
I am rewriting old FireWire based command line utility into XPCService. I need some help about an IOKit function.
Following part is to get IOCFPlugInInterface for FireWireAVCLibUnit.(almost same as original code; basic idea comes from legacy simpleAVC samplecode).
When I call IOCreatePlugInInterfaceForService() in the XPCService, it always failed returning 0xe00002be = kIOReturnNoResources in IOReturn.h.
I have confirmed no sandbox, no hardened for the XPC Service.
Original command line utility works perfectly on macOS 10.14 though, would you someone give me a hint on this topic?
CFDictionaryRef dict = CFDictionaryCreateCopy(kCFAllocatorDefault, self.dict);
kern_return_t result = IOServiceGetMatchingServices(kIOMasterPortDefault, dict, &serviceIterator);
if (result == KERN_SUCCESS && serviceIterator != IO_OBJECT_NULL) {
while ((service = IOIteratorNext(serviceIterator)) != IO_OBJECT_NULL) {
SInt32 score = 0;
kern_return_t result = IOCreatePlugInInterfaceForService(service,
kIOFireWireAVCLibUnitTypeID,
kIOCFPlugInInterfaceID,
&interface,
&score);
if (result != KERN_SUCCESS) continue;
// result 0xe00002be = kIOReturnNoResources in IOReturn.h
break;
}
}
Additional details
I have find IOCFPlugIn.c in opensource.apple.com. After basic verification,
- IOCreatePlugInInterfaceForService() failed to IOCFPlugIn->Start() .
(*iunknown)->QueryInterface(iunknown, CFUUIDGetUUIDBytes(interfaceType),
(LPVOID *)&interface);
<snip>
kr = (*interface)->Probe(interface, plist, service, &score);
<snip>
haveOne = (kIOReturnSuccess == (*interface)->Start(interface, plist, service));
Probe() returned kIOReturnSuccess though,
Start() failed w/ kIOReturnNoDevice = 0xe00002c0. and haveOne = false.
Finally IOCreatePlugInInterfaceForService() returned kIOReturnNoResources = 0xe00002be.
Is this related to some security feature on macOS?
MODIFIED
I have found hardened runtime with Camera access was rejected FireWireAVCLibUnit (tccd shows error).
Even if no sandbox, no hardened for the XPC Service in Xcode was checked, XPCservice is handled via sandbox. (macOS 10.14.6 + Xcode 10.3)
I would appreciate if you have an advice.
I have found the solution.
- Add NSCameraUsageDescription in Info.plist, and IOFireWireAVCUserClient will work.
- If sandboxed, com.apple.security.device.firewire is also required.
Even if capabilities-sandbox is off, tccd verify info.plist.
If “Privacy - Camera Usage Description” is not available, sandboxd reject to use IOFireWireAVCUserClient device.
Information Property List Key Reference/Cocoa Keys
My Meteor app is crashing when run on FireFox with this error 4 times, the fourth one must be the one crashing it because this function is called about 30 times through out the html template.;
"Exception in template helper: #http://www.scr9.com:3000 /onepage.js?6b34dec0cc55de19e1c0ff682ac83dd9dce574d6:57:2
bindDataContext/<#http://www.scr9.com:3000/packages /blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2727:14
Blaze._wrapCatchingExceptions/<#http://www.scr9.com:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1606:14
Spacebars.call#http://www.scr9.com:3000/packages/spacebars.js?7f53771c84a2eafac2b561c9796dda0d8af8e7f5:171:12
Spacebars.mustacheImpl#http://www.scr9.com:3000/packages/spacebars.js?7f53771c84a2eafac2b561c9796dda0d8af8e7f5:108:10
Spacebars.mustache#http://www.scr9.com:3000/packages/spacebars.js?7f53771c84a2eafac2b561c9796dda0d8af8e7f5:112:16
Template.writeInvoice</</</<.value#http://www.scr9.com:3000/template.onepage.js?0b87a7326f8eda037de95427f14c078c4ab026ac:1005:18
Blaze._withCurrentView#http://www.scr9.com:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2043:12
.visitAttribute#http://www.scr9.com:3000/packages/blaze.js?efa68f65"[…]
Works fine using Chrome, IE, and Safari. This is the function that it refers to at line 57;
Handlebars.registerHelper("formatMoney", function(str) {
console.log(str); // reports 0 in Chrome, IE, Safari. undefined in FF
if (typeof str == "string")
{
str = Number(str); // line 57
}
str = str.toFixed(2).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");
if (str == "0.00")
{
return "0.00";
} else {
return "$"+str;
}
});
When it first starts I have no data yet so that function is just receiving str = 0. Any idea of what might be happening in FF?
This can be because of 2 things:
First, regex, especially with a /g can cause bugs, without testing anything, I bet this is the problem.
Second, you've got a lot of coercion going on here, so first, I'd force the str argument to be a number before you pass it into the function. If this is coming from your DB this should be easy because you sanitized the data before it got in, right? right?
Implement both & your new function looks like this:
Template.registerHelper("formatMoney", function(str) {
var formatOpts = {style: "currency", currency: "USD"};
return str ? str.toLocaleString("en-US", formatOpts ) : "0.00";
});
I am using following code to fetch the path of the application. It works for all cases but fails for front row.
CFStringRef cfStrAppShortName = NULL;
FSRef appRef;
CFURLRef cfAppUrlRef = NULL;
CFBundleRef cfAppBundleRef = NULL;
CFDictionaryRef cfAppDictRef = NULL;
CFStringRef cfStrAppBundleName = NULL;
OSErr osErr;
cfStrAppShortName = CFSTR(Front Row);
if(cfStrAppShortName != NULL)
{
osErr = LSFindApplicationForInfo(kLSUnknownCreator,NULL,cfStrAppShortName,&appRef,NULL);
if(osErr == noErr)
{
cfAppUrlRef = CFURLCreateFromFSRef ( kCFAllocatorDefault, &appRef);
cfAppBundleRef = CFBundleCreate (kCFAllocatorDefault,cfAppUrlRef);
cfAppDictRef = CFBundleGetInfoDictionary (cfAppBundleRef);
cfStrAppBundleName = (CFStringRef)CFDictionaryGetValue (cfAppDictRef,kCFBundleNameKey);
}
I was expecting application path from Applications folder, but it comes from /system/coreservices/..
This happens for all items present in /system/library/coreservices/.. .
Is there any was that it should not look in /system/library/coreservices.. or any better solution?
Can anyone help me?
Thanks in Advance.
A more reliable way to identify an application is by bundle identifier. In the case of Front Row, for example, there are two separate applications with the same name:
/Applications/Front Row.app: com.apple.frontrowlauncher
/System/Library/CoreServices/Front Row.app: com.apple.frontrow
Looking at the bundle identifiers, it looks like this function is returning the path to the correct Front Row after all, since the one in /Applications is just a launcher.
But you shouldn't rely on that—the function could return the launcher's path at any time. Moreover, anybody could create an application bundle and name it “Front Row”.
Use the bundle identifier, so that you are always asking for the correct application.