I wrote a simple pytorch Sequential module for which I plan to convert to ONNX for visualisation & mobile deployment. The first step is to convert it into JIT version:
input = torch.rand(1, 3, 300, 300, dtype=torch.float32, device=device)
mod = FPNImproved(raw)
torch.jit.trace(mod, input)
This step gave me the following error:
for method_name, example_inputs in inputs.items():
# this is needed since Module.__call__ sets up some extra tracing
func = mod if method_name == "forward" else getattr(mod, method_name)
example_inputs = make_tuple(example_inputs)
> module._c._create_method_from_trace(method_name, func, example_inputs, var_lookup_fn, _force_outplace)
E RuntimeError: Only tensors or tuples of tensors can be output from traced functions (getOutput at /opt/conda/conda-bld/pytorch_1570711556059/work/torch/csrc/jit/tracer.cpp:209)
E frame #0: c10::Error::Error(c10::SourceLocation, std::string const&) + 0x47 (0x7f35dca71687 in /home/shared/conda3/envs/cv-torch/lib/python3.7/site-packages/torch/lib/libc10.so)
E frame #1: torch::jit::tracer::TracingState::getOutput(c10::IValue const&) + 0x365 (0x7f35aa607105 in /home/shared/conda3/envs/cv-torch/lib/python3.7/site-packages/torch/lib/libtorch.so)
E frame #2: torch::jit::tracer::exit(std::vector<c10::IValue, std::allocator<c10::IValue> > const&) + 0x3c (0x7f35aa60740c in /home/shared/conda3/envs/cv-torch/lib/python3.7/site-packages/torch/lib/libtorch.so)
E frame #3: <unknown function> + 0x57472a (0x7f35e62fd72a in /home/shared/conda3/envs/cv-torch/lib/python3.7/site-packages/torch/lib/libtorch_python.so)
E frame #4: <unknown function> + 0x58bbb4 (0x7f35e6314bb4 in /home/shared/conda3/envs/cv-torch/lib/python3.7/site-packages/torch/lib/libtorch_python.so)
E frame #5: <unknown function> + 0x206506 (0x7f35e5f8f506 in /home/shared/conda3/envs/cv-torch/lib/python3.7/site-packages/torch/lib/libtorch_python.so)
E frame #6: _PyMethodDef_RawFastCallKeywords + 0x254 (0x56498498e744 in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #7: _PyCFunction_FastCallKeywords + 0x21 (0x56498498e861 in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #8: _PyEval_EvalFrameDefault + 0x52f8 (0x5649849fa6e8 in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #9: _PyEval_EvalCodeWithName + 0x2f9 (0x56498493e539 in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #10: _PyFunction_FastCallKeywords + 0x325 (0x56498498def5 in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #11: _PyEval_EvalFrameDefault + 0x416 (0x5649849f5806 in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #12: _PyEval_EvalCodeWithName + 0x2f9 (0x56498493e539 in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #13: _PyFunction_FastCallKeywords + 0x325 (0x56498498def5 in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #14: _PyEval_EvalFrameDefault + 0x4b39 (0x5649849f9f29 in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #15: _PyFunction_FastCallKeywords + 0xfb (0x56498498dccb in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #16: _PyEval_EvalFrameDefault + 0x416 (0x5649849f5806 in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #17: _PyEval_EvalCodeWithName + 0x2f9 (0x56498493e539 in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #18: _PyFunction_FastCallDict + 0x400 (0x56498493f860 in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #19: _PyObject_Call_Prepend + 0x63 (0x56498495de53 in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #20: PyObject_Call + 0x6e (0x564984950dbe in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #21: _PyEval_EvalFrameDefault + 0x1e42 (0x5649849f7232 in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #22: _PyEval_EvalCodeWithName + 0x2f9 (0x56498493e539 in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #23: _PyFunction_FastCallDict + 0x400 (0x56498493f860 in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #24: _PyObject_Call_Prepend + 0x63 (0x56498495de53 in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #25: <unknown function> + 0x16ba3a (0x564984995a3a in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #26: _PyObject_FastCallKeywords + 0x49b (0x5649849968fb in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #27: _PyEval_EvalFrameDefault + 0x569f (0x5649849faa8f in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #28: _PyFunction_FastCallKeywords + 0xfb (0x56498498dccb in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #29: _PyEval_EvalFrameDefault + 0x6a3 (0x5649849f5a93 in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #30: _PyFunction_FastCallDict + 0x10b (0x56498493f56b in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #31: _PyEval_EvalFrameDefault + 0x1e42 (0x5649849f7232 in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #32: _PyEval_EvalCodeWithName + 0xac9 (0x56498493ed09 in /home/shared/conda3/envs/cv-torch/bin/python)
E frame #33: _PyFunction_FastCallKeywords + 0x387 (0x56498498df57 in /home/shared/conda3/envs/cv-torch/bin/python)
Unfortunately this message doesn't help, as I'm under the impression that all the layers in my modules already have tensors or tuples output. Even worse the error message doesn't tell me which layer is the culprit.
What is the recommended way to ask pytorch JIT to explain it? I already enabled PYTORCH_JIT=0.
I'm using pytorch 1.3.0 with only CPU support
cv2.imshow() do not pop up the window when called in the threading. An icon of python3 appears in the docker, but no window, no plot. Besides, I need the function of half-duplex communication, thus I cannot just remove threading. How can I correctly show the picture inside threading? Any response is appreciated.
Background: MacOS Catalina, python==3.5, opencv==3.4.2
import cv2
import threading
def run():
# start the camera
video_reader = cv2.VideoCapture(0)
while True:
# collect image
ret_val, image = video_reader.read()
cv2.imshow('image', image)
if cv2.waitKey(1) == 27:
break # esc to quit
t = threading.Thread(target=run, name="run")
t.start()
Some Warning messages that may help:
python3[86286:1964642] WARNING: NSWindow drag regions should only be invalidated on the Main Thread! This will throw an exception in the future. Called from (
0 AppKit 0x00007fff2fc177f0 -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 371
1 AppKit 0x00007fff2fc14ce1 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1416
2 AppKit 0x00007fff2fc14753 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 42
3 AppKit 0x00007fff2fea8368 -[NSWindow initWithContentRect:styleMask:backing:defer:screen:] + 52
4 libopencv_highgui.3.4.2.dylib 0x000000010327bee7 cvNamedWindow + 727
5 libopencv_highgui.3.4.2.dylib 0x000000010327b7a3 cvShowImage + 195
6 libopencv_highgui.3.4.2.dylib 0x000000010327860d _ZN2cv6imshowERKNS_6StringERKNS_11_InputArrayE + 477
7 cv2.cpython-35m-darwin.so 0x00000001014f8393 _ZL18pyopencv_cv_imshowP7_objectS0_S0_ + 387
8 python3 0x0000000100ca759f PyCFunction_Call + 127
9 python3 0x0000000100d6eec7 PyEval_EvalFrameEx + 18583
10 python3 0x0000000100d68faf _PyEval_EvalCodeWithName + 335
11 python3 0x0000000100c746aa function_call + 106
12 python3 0x0000000100c30b35 PyObject_Call + 69
13 python3 0x0000000100d6fc9b PyEval_EvalFrameEx + 22123
14 python3 0x0000000100d6efb8 PyEval_EvalFrameEx + 18824
15 python3 0x0000000100d6efb8 PyEval_EvalFrameEx + 18824
16 python3 0x0000000100d68faf _PyEval_EvalCodeWithName + 335
17 python3 0x0000000100c746aa function_call + 106
18 python3 0x0000000100c30b35 PyObject_Call + 69
19 python3 0x0000000100c53694 method_call + 148
20 python3 0x0000000100c30b35 PyObject_Call + 69
21 python3 0x0000000100d77bf4 PyEval_CallObjectWithKeywords + 68
22 python3 0x0000000100de472a t_bootstrap + 122
23 libsystem_pthread.dylib 0x00007fff69e8cd76 _pthread_start + 125
24 libsystem_pthread.dylib 0x00007fff69e895d7 thread_start + 15
)
2019-10-14 15:20:27.485 python3[86286:1964642] WARNING: nextEventMatchingMask should only be called from the Main Thread! This will throw an exception in the future.
Apple only allows native UI functionality to be used on the main thread in macOS and iOS.
My iPad app (XCode 6.1.1, iOS 8.1.1, ARC, Storyboards) issues this code when verifying the user wants to delete a record:
// create an action sheet
UIAlertController *view= [UIAlertController
alertControllerWithTitle:#"Warning!"
message:NSLocalizedString(#"Are you sure you want to delete this appointment?",nil)
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction* yes = [UIAlertAction
actionWithTitle:#"Yes"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[self deleteSingleAppointment];
[view dismissViewControllerAnimated:YES completion:nil];
}];
UIAlertAction* no = [UIAlertAction
actionWithTitle:#"No"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
//Do some thing here
[view dismissViewControllerAnimated:YES completion:nil];
}];
[view addAction:yes];
[view addAction:no];
view.popoverPresentationController.sourceView = self.view;
view.popoverPresentationController.sourceRect = CGRectMake(self.view.bounds.size.width / 2.0, self.view.bounds.size.height / 2.0, 1.0, 1.0);
[self presentViewController: view animated:YES completion:nil];
This code runs just fine when I run it outside the debugger on the device; this is the error shown, the stack trace follows:
UPDATED Here is the "stack trace" from 'bt':
(lldb) bt
* thread #1: tid = 0x14e4ec, 0x0000000111437dd2 CoreFoundationCFArrayGetValueAtIndex + 130, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
frame #0: 0x0000000111437dd2 CoreFoundationCFArrayGetValueAtIndex + 130
frame #1: 0x00000001137461af CoreTextTCharStream::CopyBreakIterator(__CFString const*) + 251
frame #2: 0x0000000113745f7e CoreTextTCharStream::FindLineBreak(CFRange, bool, __CFString const*) const + 274
frame #3: 0x00000001136cde9c CoreTextTTypesetter::SuggestLineBreak(TLine const&, long, double, double) + 290
frame #4: 0x00000001136cdb52 CoreTextCTLineSuggestLineBreakWithOffset + 20
frame #5: 0x000000011a6158f3 UIFoundation__NSStringDrawingEngine + 19550
frame #6: 0x000000011a610c6f UIFoundation-[NSString(NSExtendedStringDrawing) boundingRectWithSize:options:attributes:context:] + 198
frame #7: 0x000000010faa0305 UIKit-[UILabel _textRectForBounds:limitedToNumberOfLines:includingShadow:] + 1025
frame #8: 0x000000010fa9fda0 UIKit-[UILabel textRectForBounds:limitedToNumberOfLines:] + 76
frame #9: 0x000000010faa3852 UIKit-[UILabel _intrinsicSizeWithinSize:] + 170
frame #10: 0x000000010faa3932 UIKit-[UILabel intrinsicContentSize] + 76
frame #11: 0x000000010ff59ea4 UIKit-[UIView(UIConstraintBasedLayout) _generateContentSizeConstraints] + 33
frame #12: 0x000000010ff59c64 UIKit-[UIView(UIConstraintBasedLayout) _updateContentSizeConstraints] + 422
frame #13: 0x000000010ff610d6 UIKit-[UIView(AdditionalLayoutSupport) updateConstraints] + 163
frame #14: 0x000000010faa379d UIKit-[UILabel updateConstraints] + 272
frame #15: 0x000000010ff606fa UIKit-[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 248
frame #16: 0x000000010ff608f2 UIKit-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 124
frame #17: 0x0000000111455194 CoreFoundationCFArrayApplyFunction + 68
frame #18: 0x000000010ff6069b UIKit-[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 153
frame #19: 0x000000010ff608f2 UIKit-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 124
frame #20: 0x0000000111455194 CoreFoundationCFArrayApplyFunction + 68
frame #21: 0x000000010ff6069b UIKit-[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 153
frame #22: 0x000000010ff608f2 UIKit-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 124
frame #23: 0x0000000111455194 CoreFoundationCFArrayApplyFunction + 68
frame #24: 0x000000010ff6069b UIKit-[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 153
frame #25: 0x000000010ff608f2 UIKit-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 124
frame #26: 0x0000000111455194 CoreFoundationCFArrayApplyFunction + 68
frame #27: 0x000000010ff6069b UIKit-[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 153
frame #28: 0x000000010ff608f2 UIKit-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 124
frame #29: 0x0000000111455194 CoreFoundationCFArrayApplyFunction + 68
frame #30: 0x000000010ff6069b UIKit-[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 153
frame #31: 0x000000010ff608f2 UIKit-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 124
frame #32: 0x0000000111455194 CoreFoundationCFArrayApplyFunction + 68
frame #33: 0x000000010ff6069b UIKit-[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 153
frame #34: 0x000000010ff608f2 UIKit-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 124
frame #35: 0x0000000111455194 CoreFoundationCFArrayApplyFunction + 68
frame #36: 0x000000010ff6069b UIKit-[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 153
frame #37: 0x000000010ff608f2 UIKit-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 124
frame #38: 0x0000000111455194 CoreFoundationCFArrayApplyFunction + 68
frame #39: 0x000000010ff6069b UIKit-[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 153
frame #40: 0x000000010ff608f2 UIKit-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 124
frame #41: 0x0000000111455194 CoreFoundationCFArrayApplyFunction + 68
frame #42: 0x000000010ff6069b UIKit-[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 153
frame #43: 0x000000010ff608f2 UIKit-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 124
frame #44: 0x0000000111455194 CoreFoundationCFArrayApplyFunction + 68
frame #45: 0x000000010ff6069b UIKit-[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 153
frame #46: 0x000000010ff608f2 UIKit-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 124
frame #47: 0x000000010edcbd6e Foundation-[NSISEngine withBehaviors:performModifications:] + 155
frame #48: 0x000000010ff60bd4 UIKit-[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded] + 565
frame #49: 0x000000010ff541e0 UIKit-[UIWindow(UIConstraintBasedLayout) updateConstraintsIfNeeded] + 91
frame #50: 0x000000010ff6119e UIKit-[UIView(AdditionalLayoutSupport) _updateConstraintsAtEngineLevelIfNeeded] + 159
frame #51: 0x000000010f947b2d UIKit-[UIView(Hierarchy) _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] + 114
frame #52: 0x000000010f953973 UIKit-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 521
frame #53: 0x000000010f626de8 QuartzCore-[CALayer layoutSublayers] + 150
frame #54: 0x000000010f61ba0e QuartzCoreCA::Layer::layout_if_needed(CA::Transaction*) + 380
frame #55: 0x000000010f61b87e QuartzCoreCA::Layer::layout_and_display_if_needed(CA::Transaction*) + 24
frame #56: 0x000000010f58963e QuartzCoreCA::Context::commit_transaction(CA::Transaction*) + 242
frame #57: 0x000000010f58a74a QuartzCoreCA::Transaction::commit() + 390
frame #58: 0x000000010f58adb5 QuartzCoreCA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 89
frame #59: 0x0000000111481dc7 CoreFoundation__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
frame #60: 0x0000000111481d20 CoreFoundation__CFRunLoopDoObservers + 368
frame #61: 0x0000000111477b53 CoreFoundation__CFRunLoopRun + 1123
frame #62: 0x0000000111477486 CoreFoundationCFRunLoopRunSpecific + 470
frame #63: 0x00000001122de9f0 GraphicsServicesGSEventRunModal + 161
frame #64: 0x000000010f8da420 UIKitUIApplicationMain + 1282
* frame #65: 0x000000010ddba9a3 SalonBookmain(argc=3, argv=0x00007fff51e46488) + 115 at main.m:15
frame #66: 0x000000011100d145 libdyld.dylibstart + 1
(lldb)
I have restarted the Mac, but it still happens. Any idea what's causing this?
The following is a crash report I received from my crash reporting service, HockeyApp. The reason for the failure is a failure to save in PLSharedManagedObjectContext. I (think) I am doing all of my saves in the main app delegate managedObjectContext. Why is the PLSharedManagedObjectContext the one being saved to?
I think this is the relevant code:
-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
__ENTERING_METHOD__
DLog(#"info:%#",info);
NSURL *assetURL = [info objectForKey:UIImagePickerControllerReferenceURL];
__block UIImage *originalImage = [info objectForKey:UIImagePickerControllerOriginalImage];
CGSize cropSize = CGSizeMake(320,320);
CGFloat previewWindowHeight = 100.0f;
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
__block UIImage *previewImage;
if (originalImage) {
DLog(#"WE DO HAVE AN ORIGINAL IMAGE");
}
else {
DLog(#"WE DO NOT HAVE AN ORIGINAL IMAGE");
}
ImageEditor *imageEditor = [[ImageEditor alloc] initWithNibName:nil bundle:nil];
[imageEditor setRotateEnabled:NO];
[imageEditor setCheckBounds:NO];
[imageEditor setSourceImage:originalImage];
[imageEditor setPreviewHeight1:[NSNumber numberWithDouble:previewWindowHeight]];
[imageEditor setCropSize:cropSize];
imageEditor.doneCallback = ^(UIImage *editedImage, UIImage *originalImageMax1024, BOOL canceled){
picker.delegate = nil;
if(!canceled) {
if (editedImage) {
UIImage *scaledThumbnail = [HFImageEditorViewController getThumbnailForImage:editedImage size:CGSizeMake(PERSON_THUMBNAIL_SIZE,PERSON_THUMBNAIL_SIZE) round:PERSON_THUMBNAIL_ROUND];
[self setObjectCroppedImage:editedImage thumbnail:scaledThumbnail updateHeaderView:YES mocSave:NO];
[self setObjectMainImage:originalImageMax1024 mocSave:NO];
[Helper mocSave];
self.imageToShow = originalImage;
}
}
[Helper controller:self dismissControllerModal:YES];
};
[library assetForURL:assetURL resultBlock:^(ALAsset *asset) {
if (!originalImage) {
originalImage = [UIImage imageWithCGImage:[[asset defaultRepresentation] fullResolutionImage]];
}
[imageEditor setSourceImage:originalImage];
previewImage = [UIImage imageWithCGImage:[asset aspectRatioThumbnail]];
[imageEditor setPreviewImage:previewImage];
[imageEditor reset:NO];
//DLog(#"originalImage.imageOrientation:%d",originalImage.imageOrientation);
[picker pushViewController:imageEditor animated:YES];
} failureBlock:^(NSError *error) {
DLog(#"Failed to get asset from library");
if (originalImage) {
[imageEditor setSourceImage:originalImage];
[imageEditor setPreviewImage:nil];
[imageEditor reset:NO];
[picker pushViewController:imageEditor animated:YES];
}
else {
[Helper showSimpleAlertWithTitle:NSLocalizedString(#"Image Could Not Be Set", #"Image Could Not Be Set") message:NSLocalizedString(#"Failed to retrieve selected image asset from the Library.", #"Failed to retrieve selected image asset from the Library.")];
[Helper controller:self dismissControllerModal:YES];
}
}];
}
This is the crash log I am receiving:
Incident Identifier: 4DD4FE03-B8D4-4625-9039-64E4EE725AAB
CrashReporter Key: 129951E7-CF2A-4BB0-A8AB-7BA954275E29
Hardware Model: iPhone5,2
Process: MyApp [144]
Path: /Users/USER/MyApp.app/MyApp
Identifier: com.myCom.myApp
Version: 1.5.1
Code Type: ARM
Parent Process: launchd [1]
Date/Time: 2013-11-23 12:15:43 +0000
OS Version: iPhone OS 7.0.4 (11B554a)
Report Version: 104
Exception Type: SIGABRT
Exception Codes: #0 at 0x3a9031fc
Crashed Thread: 0
Application Specific Information:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Failed to save context <PLSharedManagedObjectContext: 0x157b6110>: Error Domain=NSCocoaErrorDomain Code=134030 "The operation couldn’t be completed. (Cocoa error 134030.)" (null)'
Last Exception Backtrace:
0 CoreFoundation 0x2fff6e83 __exceptionPreprocess + 131
1 libobjc.A.dylib 0x3a3536c7 objc_exception_throw + 38
2 PhotoLibraryServices 0x3667441d __copy_helper_block_279 + 1
3 CoreData 0x2fdd1855 developerSubmittedBlockToNSManagedObjectContextPerform + 89
4 libdispatch.dylib 0x3a8380af _dispatch_client_callout + 23
5 libdispatch.dylib 0x3a83a9a9 _dispatch_main_queue_callback_4CF + 268
6 CoreFoundation 0x2ffc15b1 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
7 CoreFoundation 0x2ffbfe7d __CFRunLoopRun + 1309
8 CoreFoundation 0x2ff2a471 CFRunLoopRunSpecific + 524
9 CoreFoundation 0x2ff2a253 CFRunLoopRunInMode + 106
10 GraphicsServices 0x34c642eb GSEventRunModal + 138
11 UIKit 0x327df845 UIApplicationMain + 1136
12 MyApp 0x0005b10b main (main.m:5)
13 libdyld.dylib 0x3a84cab7 start + 3
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x3a9031fc __pthread_kill + 8
1 libsystem_c.dylib 0x3a8b402d abort + 76
2 MyApp 0x002235c7 uncaught_exception_handler + 27
3 CoreFoundation 0x2fff7185 __handleUncaughtException + 581
4 libobjc.A.dylib 0x3a353927 _objc_terminate() + 175
5 libc++abi.dylib 0x39d191b3 std::__terminate(void (*)()) + 79
6 libc++abi.dylib 0x39d18a09 __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*) + 1
7 libobjc.A.dylib 0x3a35379b objc_exception_throw + 250
8 PhotoLibraryServices 0x3667441d __copy_helper_block_279 + 1
9 CoreData 0x2fdd1855 developerSubmittedBlockToNSManagedObjectContextPerform + 89
10 libdispatch.dylib 0x3a8380af _dispatch_client_callout + 23
11 libdispatch.dylib 0x3a83a9a9 _dispatch_main_queue_callback_4CF + 268
12 CoreFoundation 0x2ffc15b1 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
13 CoreFoundation 0x2ffbfe7d __CFRunLoopRun + 1309
14 CoreFoundation 0x2ff2a471 CFRunLoopRunSpecific + 524
15 CoreFoundation 0x2ff2a253 CFRunLoopRunInMode + 106
16 GraphicsServices 0x34c642eb GSEventRunModal + 138
17 UIKit 0x327df845 UIApplicationMain + 1136
18 MyApp 0x0005b10b main (main.m:5)
19 libdyld.dylib 0x3a84cab7 start + 3
Thread 1:
0 libsystem_kernel.dylib 0x3a8f0838 kevent64 + 24
1 libdispatch.dylib 0x3a839623 _dispatch_mgr_thread + 39
Thread 2:
0 libsystem_kernel.dylib 0x3a8f0a84 mach_msg_trap + 20
1 CoreFoundation 0x2ffc1559 __CFRunLoopServiceMachPort + 157
2 CoreFoundation 0x2ffbfc79 __CFRunLoopRun + 793
3 CoreFoundation 0x2ff2a471 CFRunLoopRunSpecific + 524
4 CoreFoundation 0x2ff6e0db CFRunLoopRun + 98
5 CoreMotion 0x305e2369 CLSF_thorntonUpdate_6x6 + 57225
6 libsystem_pthread.dylib 0x3a969c5d _pthread_body + 141
7 libsystem_pthread.dylib 0x3a969bcf _pthread_start + 102
8 libsystem_pthread.dylib 0x3a967cd0 thread_start + 8
Thread 3:
0 libsystem_kernel.dylib 0x3a903c7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x3a967cc4 start_wqthread + 8
Thread 4:
0 libsystem_kernel.dylib 0x3a903c7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x3a967cc4 start_wqthread + 8
Thread 5:
0 libsystem_kernel.dylib 0x3a8f0a84 mach_msg_trap + 20
1 CoreFoundation 0x2ffc1559 __CFRunLoopServiceMachPort + 157
2 CoreFoundation 0x2ffbfc79 __CFRunLoopRun + 793
3 CoreFoundation 0x2ff2a471 CFRunLoopRunSpecific + 524
4 CoreFoundation 0x2ff2a253 CFRunLoopRunInMode + 106
5 Foundation 0x309654c1 +[NSURLConnection _resourceLoadLoop:] + 320
6 Foundation 0x309dac37 __NSThread__main__ + 1063
7 libsystem_pthread.dylib 0x3a969c5d _pthread_body + 141
8 libsystem_pthread.dylib 0x3a969bcf _pthread_start + 102
9 libsystem_pthread.dylib 0x3a967cd0 thread_start + 8
Thread 6:
0 libsystem_kernel.dylib 0x3a903440 __select + 20
1 libsystem_pthread.dylib 0x3a969c5d _pthread_body + 141
2 libsystem_pthread.dylib 0x3a969bcf _pthread_start + 102
3 libsystem_pthread.dylib 0x3a967cd0 thread_start + 8
Thread 7:
0 libsystem_kernel.dylib 0x3a903c7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x3a967cc4 start_wqthread + 8
Thread 8:
0 libsystem_kernel.dylib 0x3a8f0ad4 semaphore_wait_trap + 8
1 MediaToolbox 0x31419a0f fpa_AsyncMovieControlThread + 1755
2 CoreMedia 0x30556217 figThreadMain + 195
3 libsystem_pthread.dylib 0x3a969c5d _pthread_body + 141
4 libsystem_pthread.dylib 0x3a969bcf _pthread_start + 102
5 libsystem_pthread.dylib 0x3a967cd0 thread_start + 8
Thread 9:
0 libsystem_kernel.dylib 0x3a903c7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x3a967cc4 start_wqthread + 8
Thread 0 crashed with ARM Thread State:
pc: 0x3a9031fc r7: 0x27dae3a4 sp: 0x27dae398 r0: 0x00000000
r1: 0x00000000 r2: 0x00000000 r3: 0xffffffff r4: 0x00000006
r5: 0x3c73018c r6: 0x15734ff0 r8: 0x32d7cdb2 r9: 0x3c730e30
r10: 0x32d62122 r11: 0x0000000e ip: 0x00000148 lr: 0x3a96aa53
cpsr: 0x00000010
EDIT: I think this code in ImageEditor may have something to do with it:
- (IBAction)doneAction:(id)sender
{
__ENTERING_METHOD__
self.view.userInteractionEnabled = NO;
[self startTransformHook];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
CGImageRef resultRef = [HFImageEditorViewController newTransformedImage:self.imageView.transform sourceImage:self.sourceImage.CGImage sourceSize:self.sourceImage.size sourceOrientation:self.sourceImage.imageOrientation outputWidth:self.outputWidth ? self.outputWidth : self.sourceImage.size.width cropSize:self.cropSize imageViewSize:self.imageView.bounds.size];
dispatch_async(dispatch_get_main_queue(), ^{
UIImage *transform = [UIImage imageWithCGImage:resultRef scale:1.0 orientation:UIImageOrientationUp];
CGImageRelease(resultRef);
UIImage *scaledThumbnail = [HFImageEditorViewController getThumbnailForImage:transform size:_thumbnailSize round:_thumbnailRound];
self.view.userInteractionEnabled = YES;
if(self.doneCallback) {
self.doneCallback(transform, _sourceImage, NO);
}
[self endTransformHook];
});
});
}
+ (UIImage*)getThumbnailForImage:(UIImage*)mySourceImage size:(CGSize)size round:(BOOL)round {
//TODO THIS SHOULD BE MOVED TO THE BACKGROUND
UIImage *scaledImage = [HFImageEditorViewController scaledImage:mySourceImage toSize:size withQuality:kCGInterpolationHigh];
if (round) {
CALayer *imageLayer = [CALayer layer];
imageLayer.frame = CGRectMake(0, 0, scaledImage.size.width, scaledImage.size.height);
imageLayer.contents = (id) scaledImage.CGImage;
imageLayer.masksToBounds = YES;
imageLayer.cornerRadius = scaledImage.size.width/2;
UIGraphicsBeginImageContext(scaledImage.size);
[imageLayer renderInContext:UIGraphicsGetCurrentContext()];
scaledImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
return scaledImage;
}
PLSharedManagedObjectContext appears to be an undocumented class that's part of PhotoLibraryServices.framework. That framework is itself undocumented, but the fact that it shows up in your backtrace implicates it.
As a result I don't think that this exception has anything really to do with your Core Data code. PhotoLibraryServices is using Core Data internally somewhere, and failing to do so. This might mean that you're doing something wrong with your photo handling, or it might be a framework bug. Either way, looking at your own Core Data code will almost certainly miss the point.
Having said that, there's also an indication that a performBlock call might have been involved somehow. Depending on what your mocSave method does, there might be a connection.
My App with an UIWebView is crashing a lot. The crash is often slightly different, but it's always a crash of the "WebThread" with a similar stack trace.
I found this question but I don't think it's my case, I have iOS 6 and I'm not loading Office documents.
I'm using websocket to send messages to a server and using ajax commet to receive messages from a server.
The crashes always happen when I'm starting that connections.
Date/Time: 2012-10-01 14:18:07.184 -0300
OS Version: iOS 6.0 (10A403)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000054
Crashed Thread: 4
Thread 4 name: WebThread
Thread 4 Crashed:
0 WebCore 0x35f1b9a0 WebCore::RootInlineBox::ascentAndDescentForBox(WebCore::InlineBox*, WTF::HashMap<WebCore::InlineTextBox const*, std::__1::pair<WTF::Vector<WebCore::SimpleFontData const*, 0ul>, WebCore::GlyphOverflow>, WTF::PtrHash<WebCore::InlineTextBox const*>, WTF::HashTraits<WebCore::InlineTextBox const*>, WTF::HashTraits<std::__1::pair<WTF::Vector<WebCore::SimpleFontData const*, 0ul>, WebCore::GlyphOverflow> > >&, int&, int&, bool&, bool&) const + 1344
1 WebCore 0x35f1b1a4 WebCore::InlineFlowBox::computeLogicalBoxHeights(WebCore::RootInlineBox*, int&, int&, int&, int&, bool&, bool&, bool, WTF::HashMap<WebCore::InlineTextBox const*, std::__1::pair<WTF::Vector<WebCore::SimpleFontData const*, 0ul>, WebCore::GlyphOverflow>, WTF::PtrHash<WebCore::InlineTextBox const*>, WTF::HashTraits<WebCore::InlineTextBox const*>, WTF::HashTraits<std::__1::pair<WTF::Vector<WebCore::SimpleFontData const*, 0ul>, WebCore::GlyphOverflow> > >&, WebCore::FontBaseline, WebCore::VerticalPositionCache&) + 80
2 WebCore 0x35f1ade4 WebCore::RootInlineBox::alignBoxesInBlockDirection(int, WTF::HashMap<WebCore::InlineTextBox const*, std::__1::pair<WTF::Vector<WebCore::SimpleFontData const*, 0ul>, WebCore::GlyphOverflow>, WTF::PtrHash<WebCore::InlineTextBox const*>, WTF::HashTraits<WebCore::InlineTextBox const*>, WTF::HashTraits<std::__1::pair<WTF::Vector<WebCore::SimpleFontData const*, 0ul>, WebCore::GlyphOverflow> > >&, WebCore::VerticalPositionCache&) + 124
3 WebCore 0x35f1acc2 WebCore::RenderBlock::computeBlockDirectionPositionsForLine(WebCore::RootInlineBox*, WebCore::BidiRun*, WTF::HashMap<WebCore::InlineTextBox const*, std::__1::pair<WTF::Vector<WebCore::SimpleFontData const*, 0ul>, WebCore::GlyphOverflow>, WTF::PtrHash<WebCore::InlineTextBox const*>, WTF::HashTraits<WebCore::InlineTextBox const*>, WTF::HashTraits<std::__1::pair<WTF::Vector<WebCore::SimpleFontData const*, 0ul>, WebCore::GlyphOverflow> > >&, WebCore::VerticalPositionCache&) + 54
4 WebCore 0x35f18846 WebCore::RenderBlock::createLineBoxesFromBidiRuns(WebCore::BidiRunList<WebCore::BidiRun>&, WebCore::InlineIterator const&, WebCore::LineInfo&, WebCore::VerticalPositionCache&, WebCore::BidiRun*) + 162
5 WebCore 0x35f0e30c WebCore::RenderBlock::layoutRunsAndFloatsInRange(WebCore::LineLayoutState&, WebCore::BidiResolver<WebCore::InlineIterator, WebCore::BidiRun>&, WebCore::InlineIterator const&, WebCore::BidiStatus const&, unsigned int) + 2048
6 WebCore 0x35f0cf00 WebCore::RenderBlock::layoutRunsAndFloats(WebCore::LineLayoutState&, bool) + 724
7 WebCore 0x35e4b562 WebCore::RenderBlock::layoutInlineChildren(bool, int&, int&) + 986
8 WebCore 0x35e46390 WebCore::RenderBlock::layoutBlock(bool, int) + 1132
9 WebCore 0x35e45c22 WebCore::RenderBlock::layout() + 38
10 WebCore 0x35e48cbc WebCore::RenderBlock::layoutBlockChild(WebCore::RenderBox*, WebCore::RenderBlock::MarginInfo&, int&, int&) + 556
11 WebCore 0x35e47f2c WebCore::RenderBlock::layoutBlockChildren(bool, int&) + 528
12 WebCore 0x35e463a0 WebCore::RenderBlock::layoutBlock(bool, int) + 1148
13 WebCore 0x35e45c22 WebCore::RenderBlock::layout() + 38
14 WebCore 0x35e48cbc WebCore::RenderBlock::layoutBlockChild(WebCore::RenderBox*, WebCore::RenderBlock::MarginInfo&, int&, int&) + 556
15 WebCore 0x35e47f2c WebCore::RenderBlock::layoutBlockChildren(bool, int&) + 528
16 WebCore 0x35e463a0 WebCore::RenderBlock::layoutBlock(bool, int) + 1148
17 WebCore 0x35e45c22 WebCore::RenderBlock::layout() + 38
18 WebCore 0x35e45aae WebCore::RenderView::layout() + 478
19 WebCore 0x35e404b2 WebCore::FrameView::layout(bool) + 1554
20 WebCore 0x35e782c6 WebCore::ThreadTimers::sharedTimerFiredInternal() + 134
21 WebCore 0x35e7820a WebCore::timerFired(__CFRunLoopTimer*, void*) + 62
22 CoreFoundation 0x39a615dc __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 12
23 CoreFoundation 0x39a6128c __CFRunLoopDoTimer + 268
24 CoreFoundation 0x39a5fefc __CFRunLoopRun + 1228
25 CoreFoundation 0x399d2eb8 CFRunLoopRunSpecific + 352
26 CoreFoundation 0x399d2d44 CFRunLoopRunInMode + 100
27 WebCore 0x35de4a70 RunWebThread(void*) + 440
28 libsystem_c.dylib 0x33e4730e _pthread_start + 306
29 libsystem_c.dylib 0x33e471d4 thread_start + 4
...
OS Version: iOS 6.0 (10A403)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x000000a4
Crashed Thread: 2
Thread 2 name: WebThread
Thread 2 Crashed:
0 WebCore 0x35ae72f6 WebCore::requiresLineBox(WebCore::InlineIterator const&, WebCore::LineInfo const&, WebCore::WhitespacePosition) + 30
1 WebCore 0x35ae7286 WebCore::RenderBlock::LineBreaker::skipLeadingWhitespace(WebCore::BidiResolver<WebCore::InlineIterator, WebCore::BidiRun>&, WebCore::LineInfo&, WebCore::RenderBlock::FloatingObject*, WebCore::LineWidth&) + 162
2 WebCore 0x35ae476e WebCore::RenderBlock::LineBreaker::nextLineBreak(WebCore::BidiResolver<WebCore::InlineIterator, WebCore::BidiRun>&, WebCore::LineInfo&, std::__1::pair<WebCore::RenderText*, WebCore::LazyLineBreakIterator>&, WebCore::RenderBlock::FloatingObject*, unsigned int) + 158
3 WebCore 0x35ae45de WebCore::RenderBlock::layoutRunsAndFloatsInRange(WebCore::LineLayoutState&, WebCore::BidiResolver<WebCore::InlineIterator, WebCore::BidiRun>&, WebCore::InlineIterator const&, WebCore::BidiStatus const&, unsigned int) + 2770
4 WebCore 0x35ae2f00 WebCore::RenderBlock::layoutRunsAndFloats(WebCore::LineLayoutState&, bool) + 724
5 WebCore 0x35a21562 WebCore::RenderBlock::layoutInlineChildren(bool, int&, int&) + 986
6 WebCore 0x35a1c390 WebCore::RenderBlock::layoutBlock(bool, int) + 1132
7 WebCore 0x35a1bc22 WebCore::RenderBlock::layout() + 38
8 WebCore 0x35a1ecbc WebCore::RenderBlock::layoutBlockChild(WebCore::RenderBox*, WebCore::RenderBlock::MarginInfo&, int&, int&) + 556
9 WebCore 0x35a1df2c WebCore::RenderBlock::layoutBlockChildren(bool, int&) + 528
10 WebCore 0x35a1c3a0 WebCore::RenderBlock::layoutBlock(bool, int) + 1148
11 WebCore 0x35a1bc22 WebCore::RenderBlock::layout() + 38
12 WebCore 0x35a1ecbc WebCore::RenderBlock::layoutBlockChild(WebCore::RenderBox*, WebCore::RenderBlock::MarginInfo&, int&, int&) + 556
13 WebCore 0x35a1df2c WebCore::RenderBlock::layoutBlockChildren(bool, int&) + 528
14 WebCore 0x35a1c3a0 WebCore::RenderBlock::layoutBlock(bool, int) + 1148
15 WebCore 0x35a1bc22 WebCore::RenderBlock::layout() + 38
16 WebCore 0x35a1baae WebCore::RenderView::layout() + 478
17 WebCore 0x35a164b2 WebCore::FrameView::layout(bool) + 1554
18 WebCore 0x35a4e2c6 WebCore::ThreadTimers::sharedTimerFiredInternal() + 134
19 WebCore 0x35a4e20a WebCore::timerFired(__CFRunLoopTimer*, void*) + 62
20 CoreFoundation 0x396375dc __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 12
21 CoreFoundation 0x3963728c __CFRunLoopDoTimer + 268
22 CoreFoundation 0x39635efc __CFRunLoopRun + 1228
23 CoreFoundation 0x395a8eb8 CFRunLoopRunSpecific + 352
24 CoreFoundation 0x395a8d44 CFRunLoopRunInMode + 100
25 WebCore 0x359baa70 RunWebThread(void*) + 440
26 libsystem_c.dylib 0x33a1d30e _pthread_start + 306
27 libsystem_c.dylib 0x33a1d1d4 thread_start + 4
I fixed the bug, I was sending javascript logs to cocoa like this, I fixed those crashes by removing this.
Actually, that's not necessary anymore for iOS 6 cause now it's possible to debug javascript using MAC OX safari =)