Xamarin Forms Debug Build to iPhone from PC Causes Crash - visual-studio

I'm building my first multi-platform app for android and iOS from my PC and have had no issues on the android side. I also have a mac so that I can do the iOS side of things. Set up my Mac via the microsoft guides, have a developer account and did certificates, provisioning, etc.
So I start by running the app on the iPhone 13 pro max simulator iOS 15.2 - works flawlessly. The app requires BLE functionality so obviously I can't test everything in the simulator. So I debug to my actual iPhone 13 Pro Max iOS15.2 that's plugged into my PC. App boots up and immediately the UI looks kind of strange, there are weird information display bugs that aren't present in the simulator - which looks as expected. I navigate from the main page to the second page, no issues. From the second page to the 3rd page, immediate crash, no errors, no exceptions.
Just this:
Native Crash Reporting
=================================================================
Got a abrt while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
=================================================================
Native stacktrace:
=================================================================
0x10446c1e0 - /private/var/containers/Bundle/Application/0EFE911B-4292-432A-B028-6CEB1EFAFB2A/EMBTuner.iOS.app/Xamarin.PreBuilt.iOS : mono_dump_native_crash_info
0x104462c5c - /private/var/containers/Bundle/Application/0EFE911B-4292-432A-B028-6CEB1EFAFB2A/EMBTuner.iOS.app/Xamarin.PreBuilt.iOS : mono_handle_native_crash
0x10446b728 - /private/var/containers/Bundle/Application/0EFE911B-4292-432A-B028-6CEB1EFAFB2A/EMBTuner.iOS.app/Xamarin.PreBuilt.iOS : sigabrt_signal_handler
0x1f2a5ac10 - /usr/lib/system/libsystem_platform.dylib : <redacted>
0x1b8ea45b8 - /usr/lib/system/libsystem_kernel.dylib : <redacted>
0x1b8ea45ec - /usr/lib/system/libsystem_kernel.dylib : <redacted>
0x1e9b35a54 - /System/Library/PrivateFrameworks/TCC.framework/TCC : <redacted>
0x1e9b36230 - /System/Library/PrivateFrameworks/TCC.framework/TCC : <redacted>
0x1e9b32ea8 - /System/Library/PrivateFrameworks/TCC.framework/TCC : <redacted>
0x1f2a9832c - /usr/lib/system/libxpc.dylib : <redacted>
0x1f2a8b85c - /usr/lib/system/libxpc.dylib : <redacted>
0x181b4b6e0 - /usr/lib/system/libdispatch.dylib : <redacted>
0x181b68ec8 - /usr/lib/system/libdispatch.dylib : <redacted>
0x181b5db60 - /usr/lib/system/libdispatch.dylib : <redacted>
0x1f2a6212c - /usr/lib/system/libsystem_pthread.dylib : _pthread_wqthread
0x1f2a61e94 - /usr/lib/system/libsystem_pthread.dylib : start_wqthread
=================================================================
Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x1b8ea1cf8):0x1b8ea1ce8 ff 0f 5f d6 c0 03 5f d6 30 41 80 d2 01 10
00 d4 .._..._.0A......
0x1b8ea1cf8 03 01 00 54 7f 23 03 d5 fd 7b bf a9 fd 03 00 91 ...T.#...{......
0x1b8ea1d08 4f 61
ff 97 bf 03 00 91 fd 7b c1 a8 ff 0f 5f d6 Oa.......{...._.
0x1b8ea1d18 c0 03 5f d6 90 32 80 d2 01 10 00 d4 03 01 00 54 .._..2.........T
The app has been terminated.
All I'm doing is clicking a button that calls a push navigation in the same exact way that I do from the first page.
private async void Choose_Device_Menu_OnClicked(object sender, EventArgs e)
{
await Navigation.PushAsync(new ListOfDevices(this));
}
on appearing section
protected override void OnAppearing()
{
base.OnAppearing();
}
Contructor section
namespace EMBTuner
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class ListOfDevices : ContentPage
{
private readonly IDeviceManipulationPage _page;
public ObservableCollection<IBacGenericDevice> Items { get; set; } = new ObservableCollection<IBacGenericDevice>(BacCommunication.CurrentRepository.BacDevices);
public ListOfDevices(IDeviceManipulationPage page)
{
InitializeComponent();
_page = page;
}
...
}
}
Again, it's very strange since this works perfectly on the simulator.
SOLUTION:
Adding BLE permissions within info.plist fixed the error. Wish the debugger was a bit smarter in this situation...

Related

Get GDI HFONT line height as interpreted by DrawText[Ex]

I want to know which metrics are used to calculate the correct line height (vertical distance between the baselines of 2 adjacent lines of text). "Correct" shall arbitrarily defined as "whatever DrawTextW does".
The accepted answer here appears to follow what the graph provided in this MSDN article says:
TEXTMETRICW.tmHeight + TEXTMETRICW.tmExternalLeading;
But that does not appear to be correct. Some testing with 2 pieces of text, each of which consists of 2 lines:
// RECT rc is more than large enough to fit any text
int HeightChinese = DrawTextW(hdc, L"中\r\n文", -1, &rc, 0);
int HeightLatin = DrawTextW(hdc, L"Latin,\r\nlatin!", -1, &rc, 0);
The expected return values should be 2 * <SomethingUnknown>.
One observation is that the return value of DrawTextW will always match the RECT output if DT_CALCRECT were used, for all fonts that I have on my machine. So I will assume that using DT_CALCRECT does not provide any additional value over using the return value of DrawTextW.
For all fonts on my machine, these are true:
HeightChinese == HeightLatin
LOGFONTW.lfHeight == TEXTMETRICW.tmHeight (1).
For most fonts on my machine, this is true:
HeightXxx == 2 * TEXTMETRICW.tmHeight
Which already contradicts the formula provided in the other question (TEXTMETRICW.tmExternalLeading does not play a role).
For example, "Arial" with LOGFONTW.lfHeight = 36 will have TEXTMETRICW.tmExternalLeading = 1, and HeightXxx == 72 (not 74). The distance between the lines when taking a screenshot and measuing the pixels is also 72 (so it appears that the return value can be trusted).
At the same time, "Segoe UI" with LOGFONTW.lHeight = 43 will have TEXTMETRICW.tmExternalLeading = 0, and HeightXxx == 84 (not 86).
This is a list of all anomalous fonts on my system:
"FontName" -- "DrawText return value" vs "2 * TEXTMETRICW.tmHeight"
Ebrima -- 84 vs 86
Leelawadee UI -- 84 vs 86
Leelawadee UI Semilight -- 84 vs 86
Lucida Sans Unicode -- 96 vs 98
Malgun Gothic -- 84 vs 86
Malgun Gothic Semilight -- 84 vs 86
Microsoft Tai Le -- 80 vs 82
Microsoft YaHei -- 82 vs 84
Microsoft YaHei UI Light -- 82 vs 84
MS Gothic -- 66 vs 64
MS UI Gothic -- 66 vs 64
MS PGothic -- 66 vs 64
Nirmala UI -- 84 vs 86
Nirmala UI Semilight -- 84 vs 86
Palatino Linotype -- 84 vs 86
Segoe UI -- 84 vs 86
Segoe UI Black -- 84 vs 86
Segoe UI Historic -- 84 vs 86
Segoe UI Light -- 84 vs 86
Segoe UI Semibold -- 84 vs 86
Segoe UI Semilight -- 84 vs 86
Segoe UI Symbol -- 84 vs 86
SimSun -- 66 vs 64
NSimSun -- 66 vs 64
SimSun-ExtB -- 66 vs 64
Verdana -- 76 vs 78
Webdings -- 62 vs 64
Yu Gothic UI -- 84 vs 86
Yu Gothic UI Semibold -- 84 vs 86
Yu Gothic UI Light -- 84 vs 86
Yu Gothic UI Semilight -- 84 vs 86
MS Mincho -- 66 vs 64
MS PMincho -- 66 vs 64
Ubuntu Mono -- 62 vs 64
Sometimes the return value is 2 bigger, sometimes it is 2 smaller than the calculated value.
I have looked at the other values in TEXTMETRICW, and I've also looked at the extra data available int OUTLINETEXTMETRICW, but I could not find any pattern that would explain the observations.
So then, what are the correct metrics to calculate line height? I understand that I could call DrawTextW with DT_CALCRECT to get this value, but I want to understand where this information comes from (and thus, how a font designer could control it in a predictable way).
Here is a gist with a complete Windows application that demonstrates this. All the interesting stuff is in WM_PAINT. Search for #EDIT for some interesting code switches and breakpoints. At the time of posting this question, my GitHub account has been flagged, and the Gist is temporarily unavailable. I hope this can be resolved quickly.
(1) I am using EnumFontFamiliesEx to enumerate all fonts, and it happens to provide LOGFONTW structs with positive lfHeight values. That means I am using cell height rather than character height. While character height is the more typical way of specifying font height, that is sort of irrelevant here, it just so happens that cell height is equal to TEXTMETRICW.tmHeight, but character height isn't. The relevant value for calculations is TEXTMETRICW.tmHeight, and not LOGFONTW.lfHeight.
As Jonathan Potter pointed out, the formula TEXTMETRICW.tmHeight should have been correct, and if the DT_EXTERNALLEADING flag is set, then it's TEXTMETRICW.tmHeight + TEXTMETRICW.tmExternalLeading.
I reverse-engineered DrawTextExW with Ghidra and the reason the numbers were sometimes off is not DrawTextExW itself. DrawTextExW internally uses a DT_InitDrawTextInfo, which in turn uses GetTextMetricsW and calculates the line height according to the above formula.
However, consider this code to probe all fonts:
LOGFONTW Probe = {};
Probe.lfCharSet = DEFAULT_CHARSET;
EnumFontFamiliesExW(hdc, &Probe, InitializeFontInfo_EnumFontFamiliesCallback, NULL, 0);
static int CALLBACK InitializeFontInfo_EnumFontFamiliesCallback(const LOGFONTW *LogFont, const TEXTMETRICW *TextMetric, DWORD FontType, LPARAM lParam)
{
FONT_INFO tmp = {};
tmp.LogFont = *LogFont;
tmp.TextMetric = *TextMetric;
FontInfo.push_back(tmp);
return 1;
}
Here, for the Segoe UI font, for example, LogFont->lfHeight will be 43.
And so, TextMetric->tmHeight will also be 43, which, you would think, makes sense to some degree.
However:
If you go ahead and select this LogFont into a HDC, and then use GetTextMetricsW, like so:
HFONT Font = CreateFontIndirectW(LogFont);
SelectObject(hdc, Font);
TEXTMETRICW TextMetric = {};
GetTextMetricsW(hdc, &TextMetric);
Then TextMetric->tmHeight == 42 even though LogFont->lfHeight == 43.
In other words, the values provided to the EnumFontFamiliesExW callback for its TEXTMETRICW parameter cannot be trusted. Although you could argue that the bug is elsewhere, and selecting a LogFont->lfHeight == 43 font should really also produce a TextMetric->tmHeight == 43 text metric, but I suppose that's too much to ask. My guess is that there's a floating point conversion going on somewhere in there, and that occasionally produces a rounding error for some numbers.
DrawText() only uses TEXTMETRIC.tmExternalLeading if the DT_EXTERNALLEADING flag is set when you call it - you don't seem to have taken that into account.
The line height formula is basically:
int iLineHeight = tm.tmHeight + ((format & DT_EXTERNALLEADING) ? tm.tmExternalLeading : 0);

How to show my source code in stack trace for Xamarin iOS app?

My Xamarin iOS app crashes with error "unrecognized selector sent to instance...", but neither the stack trace nor the call stack has any useful information of where could be the problem in my source code. I'm using Visual Studio for Mac, and the app is running on the iOS simulator. Are there any options that need to be enabled in order to show my source code in the stack trace?
Unhandled Exception:
Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[NSObject doesNotRecognizeSelector]: unrecognized selector sent to instance 0x600000016d80
Native stack trace:
0 CoreFoundation 0x000000010579e12b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00000001066d8f41 objc_exception_throw + 48
2 CoreFoundation 0x000000010581f024 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x0000000105720f78 ___forwarding___ + 1432
4 CoreFoundation 0x0000000105720958 _CF_forwarding_prep_0 + 120
5 Foundation 0x0000000103997f35 __NSFireDelayedPerform + 409
6 CoreFoundation 0x000000010572e174 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
7 CoreFoundation 0x000000010572de32 __CFRunLoopDoTimer + 1026
8 CoreFoundation 0x000000010572d9ea __CFRunLoopDoTimers + 266
9 CoreFoundation 0x0000000105725404 __CFRunLoopRun + 2308
10 CoreFoundation 0x0000000105724889 CFRunLoopRunSpecific + 409
11 GraphicsServices 0x0000000108cfb9c6 GSEventRunModal + 62
12 UIKit 0x00000001013375d6 UIApplicationMain + 159
13 ??? 0x00000001179fbe98 0x0 + 4691312280
14 ??? 0x00000001179fbac3 0x0 + 4691311299
Update:
The problem seems related to .dSYM files not being generated for the simulator.
This is what I add to my Application.cs class to better see exception information:
static void Main(string[] args)
{
#if DEBUG
try
{
#endif
UIApplication.Main(args, null, "AppDelegate");
#if DEBUG
}
catch (Exception ex)
{
var msg = ex.Message;
var temp = ex.StackTrace;
if(System.Diagnostics.Debugger.IsAttached)
System.Diagnostics.Debugger.Break();
throw;
}
#endif
}
You can trace inside xamarin source code. Details specified in Microsoft documentation.
Also you can get more diagnostic details during debugging by changing Xamarin options as specified in Xamarin forums.

Why is XCode giving me an 'unrecognized selector' error?

I'm developing a Mac app using Swift 2 and Xcode 7.
I'm just getting started with Swift after many years focused on Ruby with a touch of JavaScript.
The Mac app that I'm creating includes a web browser view.
My ViewController.swift says:
import Cocoa
import WebKit
class ViewController: NSViewController {
#IBOutlet var url: NSTextField!
#IBOutlet var browser: WKWebView!
#IBAction func go(sender: AnyObject) {
// browser.loadRequest(NSURLRequest(URL:NSURL(string: url.stringValue)!))
// above line broken down for debugging
let url1 = url.stringValue
print("url1 = \(url1)")
let url2 = NSURL(string: url1)!
print("url2 = \(url2)")
let url3 = NSURLRequest(URL:url2)
print("url3 = \(url3)")
print("browser is \(browser)")
browser.loadRequest(url3)
}
}
The app builds successfully. When I run it, enter http://apple.com into the URL field and click the Go button, I see:
url1 = http://apple.com
url2 = http://apple.com
url3 = <NSURLRequest: 0x600000001400> { URL: http://apple.com }
browser is <WebView: 0x608000120e60>
2016-04-06 13:39:51.664 Testivate[6516:427535] -[WebView loadRequest:]: unrecognized selector sent to instance 0x608000120e60
2016-04-06 13:39:51.664 Testivate[6516:427535] -[WebView loadRequest:]: unrecognized selector sent to instance 0x608000120e60
2016-04-06 13:39:51.667 Testivate[6516:427535] (
0 CoreFoundation 0x00007fff93f4a4f2 __exceptionPreprocess + 178
1 libobjc.A.dylib 0x00007fff8ca7a73c objc_exception_throw + 48
2 CoreFoundation 0x00007fff93fb41ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00007fff93eba571 ___forwarding___ + 1009
4 CoreFoundation 0x00007fff93eba0f8 _CF_forwarding_prep_0 + 120
5 Testivate 0x000000010000271a _TFC9Testivate14ViewController2gofPs9AnyObject_T_ + 2154
6 Testivate 0x00000001000027b6 _TToFC9Testivate14ViewController2gofPs9AnyObject_T_ + 54
7 libsystem_trace.dylib 0x00007fff96e1807a _os_activity_initiate + 75
8 AppKit 0x00007fff94567e89 -[NSApplication sendAction:to:from:] + 460
9 AppKit 0x00007fff94579fde -[NSControl sendAction:to:] + 86
10 AppKit 0x00007fff94579f08 __26-[NSCell _sendActionFrom:]_block_invoke + 131
11 libsystem_trace.dylib 0x00007fff96e1807a _os_activity_initiate + 75
12 AppKit 0x00007fff94579e65 -[NSCell _sendActionFrom:] + 144
13 libsystem_trace.dylib 0x00007fff96e1807a _os_activity_initiate + 75
14 AppKit 0x00007fff9457848a -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2693
15 AppKit 0x00007fff945c0fd0 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 744
16 AppKit 0x00007fff94576bb4 -[NSControl mouseDown:] + 669
17 AppKit 0x00007fff94acb469 -[NSWindow _handleMouseDownEvent:isDelayedEvent:] + 6322
18 AppKit 0x00007fff94acc44d -[NSWindow _reallySendEvent:isDelayedEvent:] + 212
19 AppKit 0x00007fff9450b63d -[NSWindow sendEvent:] + 517
20 AppKit 0x00007fff9448bb3c -[NSApplication sendEvent:] + 2540
21 AppKit 0x00007fff942f2ef6 -[NSApplication run] + 796
22 AppKit 0x00007fff942bc46c NSApplicationMain + 1176
23 Testivate 0x0000000100004f34 main + 84
24 libdyld.dylib 0x00007fff9099a5ad start + 1
25 ??? 0x0000000000000003 0x0 + 3
)
Initially I thought the error was saying that loadRequest was an unrecognized selector for browser, but you can see I've pulled apart the function and browser is clearly an instance of WebView, which definitely has loadRequest as a method. You can see from how I've pulled apart the method that I'm definitely providing the loadRequest method with the expected NSURLRequest object.
I'm now thinking that maybe this has something to do with being unable to find the WebView in Main.storyboard, but surely it should be able to? I've defined connections on it like this:
When you view Main.storyboard as source, it says:
<webView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Ocj-mD-woP">
<rect key="frame" x="62" y="20" width="406" height="211"/>
<webPreferences key="preferences" defaultFontSize="12" defaultFixedFontSize="12">
<nil key="identifier"/>
</webPreferences>
</webView>
Any thoughts? Thanks.
You're mixing up two different kinds of web views.
In your code, you're saying that browser is a WKWebView. That's the newer kind of web view, that was first available in OS X 10.10. It has a method named -loadView: in Objective-C, or loadView() in Swift.
#IBOutlet var browser: WKWebView!
However, when you run the code, the object is actually a WebView, because that's what you put in your storyboard. That's an older kind of web view. It doesn't have a method named -loadView: so you get an error when you try to call it.
browser is <WebView: 0x608000120e60>
-[WebView loadRequest:]: unrecognized selector sent to instance 0x608000120e60
(Read the documentation you linked to again. The WebView's main frame implements -loadRequest:, but WebView does not.)
Here are two possible fixes:
Easier: Fix your code to use WebView correctly, but leave the storyboard the same.
#IBOutlet var browser: WebView!
...
browser.mainFrame.loadRequest(url3)
Harder: Keep the code using WKWebView, but remove the WebView from your storyboard.
Unfortunately it's currently impossible to put a WKWebView in a storyboard, so you will have to write some code to set it up yourself. See the linked answer for an example of how to do it.
If you want to take advantage of the new features of WKWebView, you'll have to use the second alternative.

Firefox Extension/Addon - Detect workspace locked

I'm searching for a solution in my firefox addon to detect when the user workspace has locked/released. In google chrome there is an easy API chrome.idle.onStateChanged.addListener for it, is there something similar in firefox or any possibility to do that, platform independent?
By the way, I use the addon sdk.
I've already tried the idle service:
Cc["#mozilla.org/widget/idleservice;1"].getService(Ci.nsIIdleService)
but I just gives me access to some idle timeout or system when go to sleep and not to just workspace locked.
Edit: With "workspace locked" I mean the user lock the workspace with ctrl + alt + delete. I don't know how this exactly work on OSX or linux.
Edit2: I working in Windows 8.1 currently, but I guess the chrome.idle handler works cross platform.
Edit3: What i currently get out of current answers is
1. That there not exist a cross-platform solution, neither in chrome nor in firefox.
chrome.idle.onStateChanged seems to work different on windows, linux and osx. Only windows can handle that "locked" behaviour as expected. I can't test OSX, on ubuntu 14 it doesn't work for me.
2. For firefox there some in-depth code things to try to make it working - see answer bellow from Noitidart in this topic.
Edit4: Noitidart have found a solution for windows - github link.
I don't know how to detect screen lock but there are these observer notifications:
https://developer.mozilla.org/en-US/docs/Observer_Notifications#Idle_Service
Also the computer sleep wake notifications. ill ask around for lock screen thats an interesting one.
Some useful chat about the subject, looking at how google chrome does it:
[12:33] ok guys question about actual work. anyone know how to detect if screen was locked? apparently google chrome has a method: https://developer.chrome.com/extensions/idle#event-onStateChanged
[12:45] anyone know of a MXR or DXR for google chromes codebase?
[12:46] mxr.mozilla.org/chromium
[12:52] Ms2ger: can you help me find how they test screen lock. im looking here: http://mxr.mozilla.org/chromium/source/src/chrome/browser/extensions/api/idle/idle_api_unittest.cc#84
[12:56] oh yuck it looks like they poll: http://mxr.mozilla.org/chromium/source/src/chrome/browser/extensions/api/idle/idle_manager.h#118
maybe they arent polling.
check this out:
http://mxr.mozilla.org/chromium/source/src/chrome/browser/extensions/api/idle/idle_manager.cc#246
244 void IdleManager::UpdateIdleStateCallback(int idle_time) {
245 DCHECK(thread_checker_.CalledOnValidThread());
246 bool locked = idle_time_provider_->CheckIdleStateIsLocked();
247 int listener_count = 0;
leads to: http://mxr.mozilla.org/chromium/source/src/chrome/browser/idle_win.cc#52
52 bool CheckIdleStateIsLocked() {
53 return ui::IsWorkstationLocked() || IsScreensaverRunning();
54 }
so this leads us to test if screensaver running or workstation locked
leads to:
http://mxr.mozilla.org/chromium/search?string=IsWorkstationLocked
we see just one implementation (its curious because there is no linux support but it doesnt say so on the chrome docs page, so maybe i couldnt find it)
Windows
http://mxr.mozilla.org/chromium/source/src/ui/base/win/lock_state.cc#11
11 bool IsWorkstationLocked() {
12 bool is_locked = true;
13 HDESK input_desk = ::OpenInputDesktop(0, 0, GENERIC_READ);
14 if (input_desk) {
15 wchar_t name[256] = {0};
16 DWORD needed = 0;
17 if (::GetUserObjectInformation(
18 input_desk, UOI_NAME, name, sizeof(name), &needed)) {
19 is_locked = lstrcmpi(name, L"default") != 0;
20 }
21 ::CloseDesktop(input_desk);
22 }
23 return is_locked;
24 }
Mac
see the screensaver section below, the screenlock is handled via there as well
http://mxr.mozilla.org/chromium/search?string=IsScreensaverRunning&find=&findi=&filter=^%5B^\0%5D*%24&hitlimit=&tree=chromium
we see in this search results 2 implementations, mac and windows it looks like no support for linux, which is curious because the chrome.idle page doesnt mention this on docs, maybe i just couldnt find it
windows implementation: http://mxr.mozilla.org/chromium/source/src/chrome/browser/idle_win.cc#39
39 bool IsScreensaverRunning() {
40 DWORD result = 0;
41 if (::SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, &result, 0))
42 return result != FALSE;
43 return false;
44 }
45
mac implementation: http://mxr.mozilla.org/chromium/source/src/chrome/browser/idle_mac.mm#28
28 - (id)init {
29 if ((self = [super init])) {
30 NSDistributedNotificationCenter* distCenter =
31 [NSDistributedNotificationCenter defaultCenter];
32 [distCenter addObserver:self
33 selector:#selector(onScreenSaverStarted:)
34 name:#"com.apple.screensaver.didstart"
35 object:nil];
36 [distCenter addObserver:self
37 selector:#selector(onScreenSaverStopped:)
38 name:#"com.apple.screensaver.didstop"
39 object:nil];
40 [distCenter addObserver:self
41 selector:#selector(onScreenLocked:)
42 name:#"com.apple.screenIsLocked"
43 object:nil];
44 [distCenter addObserver:self
45 selector:#selector(onScreenUnlocked:)
46 name:#"com.apple.screenIsUnlocked"
47 object:nil];
48 }
49 return self;
50 }
so to sum this all up:
[13:32] for windows its peice of cake winapi has call to test if screen is locked or scrensaver running
[13:32] for mac they dont have screen lock test. they just have screensaver test, but its an observer method
[13:32] for linux they dont have screen lock nor screen saver test. real odd. ill ask the guy if he knows which os's they support chrome.idle in
edit: actually i found the linux implementation. back from the search results of: CheckIdleStateLocked: http://mxr.mozilla.org/chromium/search?string=CheckIdleStateIsLocked
http://mxr.mozilla.org/chromium/source/src/chrome/browser/idle_linux.cc#24
24 bool CheckIdleStateIsLocked() {
25 // Usually the screensaver is used to lock the screen, so we do not need to
26 // check if the workstation is locked.
27 #if defined(OS_CHROMEOS)
28 return false;
29 #elif defined(USE_OZONE)
30 return false;
31 #else
32 return ScreensaverWindowFinder::ScreensaverWindowExists();
33 #endif
34 }
Leads to ask how is ScreensaverWindowExists we find this: http://mxr.mozilla.org/chromium/source/src/chrome/browser/screensaver_window_finder_x11.cc
15 bool ScreensaverWindowFinder::ScreensaverWindowExists() {
16 gfx::X11ErrorTracker err_tracker;
17 ScreensaverWindowFinder finder;
18 ui::EnumerateTopLevelWindows(&finder);
19 return finder.exists_ && !err_tracker.FoundNewError();
20 }
Leads to what is EnumerateTopLevelWindows http://mxr.mozilla.org/chromium/source/src/ui/base/x/x11_util.cc#1059:
1059 void EnumerateTopLevelWindows(ui::EnumerateWindowsDelegate* delegate) {
1060 std::vector<XID> stack;
1061 if (!ui::GetXWindowStack(ui::GetX11RootWindow(), &stack)) {
1062 // Window Manager doesn't support _NET_CLIENT_LIST_STACKING, so fall back
1063 // to old school enumeration of all X windows. Some WMs parent 'top-level'
1064 // windows in unnamed actual top-level windows (ion WM), so extend the
1065 // search depth to all children of top-level windows.
1066 const int kMaxSearchDepth = 1;
1067 ui::EnumerateAllWindows(delegate, kMaxSearchDepth);
1068 return;
1069 }
1070 XMenuList::GetInstance()->InsertMenuWindowXIDs(&stack);
1071
1072 std::vector<XID>::iterator iter;
1073 for (iter = stack.begin(); iter != stack.end(); iter++) {
1074 if (delegate->ShouldStopIterating(*iter))
1075 return;
1076 }
1077 }
1078
We say they call delegate->ShouldStopIterating which was seen in same file as ScreensaverWindowExists: http://mxr.mozilla.org/chromium/source/src/chrome/browser/screensaver_window_finder_x11.cc
22 bool ScreensaverWindowFinder::ShouldStopIterating(XID window) {
23 if (!ui::IsWindowVisible(window) || !IsScreensaverWindow(window))
24 return false;
25 exists_ = true;
26 return true;
27 }
Leads to ask what is IsWindowVisible and IsScreensaverWindow
*IsScreensaverWindow, in same file of ScreensaverWindowExists: http://mxr.mozilla.org/chromium/source/src/chrome/browser/screensaver_window_finder_x11.cc
29 bool ScreensaverWindowFinder::IsScreensaverWindow(XID window) const {
30 // It should occupy the full screen.
31 if (!ui::IsX11WindowFullScreen(window))
32 return false;
33
34 // For xscreensaver, the window should have _SCREENSAVER_VERSION property.
35 if (ui::PropertyExists(window, "_SCREENSAVER_VERSION"))
36 return true;
37
38 // For all others, like gnome-screensaver, the window's WM_CLASS property
39 // should contain "screensaver".
40 std::string value;
41 if (!ui::GetStringProperty(window, "WM_CLASS", &value))
42 return false;
43
44 return value.find("screensaver") != std::string::npos;
45 }
IsWindowVisible: http://mxr.mozilla.org/chromium/source/src/ui/base/x/x11_util.cc#546
546 bool IsWindowVisible(XID window) {
547 TRACE_EVENT0("ui", "IsWindowVisible");
548
549 XWindowAttributes win_attributes;
550 if (!XGetWindowAttributes(gfx::GetXDisplay(), window, &win_attributes))
551 return false;
552 if (win_attributes.map_state != IsViewable)
553 return false;
554
555 // Minimized windows are not visible.
556 std::vector<XAtom> wm_states;
557 if (GetAtomArrayProperty(window, "_NET_WM_STATE", &wm_states)) {
558 XAtom hidden_atom = GetAtom("_NET_WM_STATE_HIDDEN");
559 if (std::find(wm_states.begin(), wm_states.end(), hidden_atom) !=
560 wm_states.end()) {
561 return false;
562 }
563 }

xcode 4.5 crash log symbolicates except for app lines

How to I get to symbolicate everything?
Here is an example so what I am talking about:
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 CoreFoundation 0x351642cc CFRelease + 32
1 CoreFoundation 0x3518e130 CFArraySetValueAtIndex + 284
2 AddressBook 0x32971aba ABCMultiValueReplaceLabel + 58
3 AddressBook 0x3298c598 ABMultiValueReplaceLabelAtIndex + 140
4 My App 0x00011206 0x00011206
5 My App 0x00010e48 0x00010e48
6 My App 0x00011ada 0x00011ada
7 My App 0x0001027c 0x0001027c
8 My App 0x0000ecf2 0x0000ecf2
9 My App 0x00012f44 0x00012f44
10 My App 0x00012e3e 0x00012e3e
11 Foundation 0x32d0aef2 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke_0 + 14
12 Foundation 0x32c4a9ec -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 196
13 Foundation 0x32c4a908 -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 56
14 CFNetwork 0x3111c5dc ___delegate_didFinishLoading_block_invoke_0 + 24
15 CFNetwork 0x3111bcc8 ___withDelegateAsync_block_invoke_0 + 52
16 CFNetwork 0x31144130 ___performAsync_block_invoke_068 + 16
17 CoreFoundation 0x3516974a CFArrayApplyFunction + 174
18 CFNetwork 0x3114458e RunloopBlockContext::perform() + 70
19 CFNetwork 0x310a815a MultiplexerSource::perform() + 186
20 CoreFoundation 0x351f8680 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
21 CoreFoundation 0x351f7ee4 __CFRunLoopDoSources0 + 208
22 CoreFoundation 0x351f6cb2 __CFRunLoopRun + 642
23 CoreFoundation 0x35169eb8 CFRunLoopRunSpecific + 352
24 CoreFoundation 0x35169d44 CFRunLoopRunInMode + 100
25 GraphicsServices 0x356a62e6 GSEventRunModal + 70
26 UIKit 0x365482fc UIApplicationMain + 1116
27 My App 0x0000275a 0x0000275a
28 My App 0x00002714 0x00002714
You might find these links useful on how to symbolicate crash logs:
Symbolicating iPhone App Crash Reports
iOS Crash Logs
Another way: in Xcode 4.5, set your build target (via the Scheme drop down next to the Stop button) to an iOS Device. Then go to the Product menu in the menu bar and choose Archive.
Next, open the Organizer window (Window menu in the menu bar --> Organizer), and make sure your app shows up in the list when you click the Archives icon at the top of the Organizer window.
Finally, click the Devices icon at the top of the Organizer window, click Device Logs on the left under Library, and drag your crash log into the pane on the right. It should be fully auto-symbolicated for you.

Resources