diff --git a/Sources/Sentry/Profiling/SentryProfiledTracerConcurrency.mm b/Sources/Sentry/Profiling/SentryProfiledTracerConcurrency.mm index bdb2de79260..f809cbd1f92 100644 --- a/Sources/Sentry/Profiling/SentryProfiledTracerConcurrency.mm +++ b/Sources/Sentry/Profiling/SentryProfiledTracerConcurrency.mm @@ -125,6 +125,9 @@ # if SENTRY_HAS_UIKIT profiler.screenFrameData = [SentryDependencyContainer.sharedInstance.framesTracker.currentFrames copy]; + SENTRY_LOG_DEBUG( + @"Grabbing copy of frames tracker screen frames data to attach to profiler: %@.", + profiler.screenFrameData); if (_gProfilersToTracers.count == 0) { [SentryDependencyContainer.sharedInstance.framesTracker resetProfilingTimestamps]; } diff --git a/Sources/Sentry/Profiling/SentryProfilerState.mm b/Sources/Sentry/Profiling/SentryProfilerState.mm index 27e214fa72d..437c9f235cd 100644 --- a/Sources/Sentry/Profiling/SentryProfilerState.mm +++ b/Sources/Sentry/Profiling/SentryProfilerState.mm @@ -1,5 +1,6 @@ #import "SentryProfilerState.h" #if SENTRY_TARGET_PROFILING_SUPPORTED +# import "SentryAsyncSafeLog.h" # import "SentryBacktrace.hpp" # import "SentryDependencyContainer.h" # import "SentryDispatchQueueWrapper.h" @@ -121,7 +122,8 @@ - (void)appendBacktrace:(const Backtrace &)backtrace const auto symbols = backtrace_symbols(reinterpret_cast(backtrace.addresses.data()), static_cast(backtrace.addresses.size())); -# endif + const auto *backtraceFunctionNames = [NSMutableArray array]; +# endif // defined(DEBUG) const auto stack = [NSMutableArray array]; for (std::vector::size_type backtraceAddressIdx = 0; @@ -133,8 +135,10 @@ - (void)appendBacktrace:(const Backtrace &)backtrace const auto frame = [NSMutableDictionary dictionary]; frame[@"instruction_addr"] = instructionAddress; # if defined(DEBUG) - frame[@"function"] + const auto functionName = parseBacktraceSymbolsFunctionName(symbols[backtraceAddressIdx]); + frame[@"function"] = functionName; + [backtraceFunctionNames addObject:functionName]; # endif const auto newFrameIndex = @(state.frames.count); [stack addObject:newFrameIndex]; @@ -146,7 +150,7 @@ - (void)appendBacktrace:(const Backtrace &)backtrace } # if defined(DEBUG) free(symbols); -# endif +# endif // defined(DEBUG) const auto sample = [[SentrySample alloc] init]; sample.absoluteTimestamp = backtrace.absoluteTimestamp; @@ -165,6 +169,14 @@ - (void)appendBacktrace:(const Backtrace &)backtrace [state.stacks addObject:stack]; } +# if defined(DEBUG) + if (backtraceFunctionNames.count > 0) { + SENTRY_ASYNC_SAFE_LOG_DEBUG("Recorded backtrace for thread %s at %llu: %s", + threadID.UTF8String, sample.absoluteTimestamp, + backtraceFunctionNames.description.UTF8String); + } +# endif // defined(DEBUG) + [state.samples addObject:sample]; }]; } diff --git a/Sources/Sentry/SentryFramesTracker.m b/Sources/Sentry/SentryFramesTracker.m index 6c5908bf16c..44f1e911ef8 100644 --- a/Sources/Sentry/SentryFramesTracker.m +++ b/Sources/Sentry/SentryFramesTracker.m @@ -135,6 +135,7 @@ - (void)resetProfilingTimestamps - (void)resetProfilingTimestampsInternal { + SENTRY_LOG_DEBUG(@"Resetting profiling GPU timeseries data."); self.frozenFrameTimestamps = [SentryMutableFrameInfoTimeSeries array]; self.slowFrameTimestamps = [SentryMutableFrameInfoTimeSeries array]; self.frameRateTimestamps = [SentryMutableFrameInfoTimeSeries array]; diff --git a/Sources/Sentry/SentryHttpTransport.m b/Sources/Sentry/SentryHttpTransport.m index 3df7a3fb689..edf520ba901 100644 --- a/Sources/Sentry/SentryHttpTransport.m +++ b/Sources/Sentry/SentryHttpTransport.m @@ -294,12 +294,14 @@ - (void)sendAllCachedEnvelopes SentryEnvelope *envelope = [SentrySerialization envelopeWithData:envelopeFileContents.contents]; if (nil == envelope) { + SENTRY_LOG_DEBUG(@"Envelope contained no deserializable data."); [self deleteEnvelopeAndSendNext:envelopeFileContents.path]; return; } SentryEnvelope *rateLimitedEnvelope = [self.envelopeRateLimit removeRateLimitedItems:envelope]; if (rateLimitedEnvelope.items.count == 0) { + SENTRY_LOG_DEBUG(@"Envelope had no rate-limited items, nothing to send."); [self deleteEnvelopeAndSendNext:envelopeFileContents.path]; return; } @@ -313,6 +315,7 @@ - (void)sendAllCachedEnvelopes didFailWithError:&requestError]; if (nil != requestError) { + SENTRY_LOG_DEBUG(@"Failed to build request: %@.", requestError); [self recordLostEventFor:rateLimitedEnvelope.items]; [self deleteEnvelopeAndSendNext:envelopeFileContents.path]; return; @@ -354,12 +357,13 @@ - (void)sendEnvelope:(SentryEnvelope *)envelope return; } - // If the response is not nil we had an internet connection. if (error && response.statusCode != 429) { + SENTRY_LOG_DEBUG(@"Request error other than rate limit: %@", error); [weakSelf recordLostEventFor:envelope.items]; } if (nil != response) { + SENTRY_LOG_DEBUG(@"Envelope sent successfully!"); [weakSelf.rateLimits update:response]; [weakSelf deleteEnvelopeAndSendNext:envelopePath]; } else { @@ -371,7 +375,6 @@ - (void)sendEnvelope:(SentryEnvelope *)envelope - (void)finishedSending { - SENTRY_LOG_DEBUG(@"Finished sending."); @synchronized(self) { self.isSending = NO; if (self.isFlushing) { diff --git a/Sources/Sentry/SentryNSURLRequest.m b/Sources/Sentry/SentryNSURLRequest.m index 22b840c5700..7d9b79ccae1 100644 --- a/Sources/Sentry/SentryNSURLRequest.m +++ b/Sources/Sentry/SentryNSURLRequest.m @@ -95,6 +95,8 @@ - (instancetype)initEnvelopeRequestWithURL:(NSURL *)url forHTTPHeaderField:@"User-Agent"]; [self setValue:@"gzip" forHTTPHeaderField:@"Content-Encoding"]; self.HTTPBody = sentry_gzippedWithCompressionLevel(data, -1, error); + + SENTRY_LOG_DEBUG(@"Constructed request: %@", self); } return self; diff --git a/Sources/Sentry/SentryScreenFrames.m b/Sources/Sentry/SentryScreenFrames.m index 2bf64957e62..6b2ce14d64a 100644 --- a/Sources/Sentry/SentryScreenFrames.m +++ b/Sources/Sentry/SentryScreenFrames.m @@ -78,6 +78,19 @@ - (nonnull id)copyWithZone:(nullable NSZone *)zone # endif // SENTRY_TARGET_PROFILING_SUPPORTED +- (NSString *)description +{ + NSMutableString *result = [NSMutableString + stringWithFormat:@"Total frames: %lu; slow frames: %lu; frozen frames: %lu", + (unsigned long)_total, (unsigned long)_slow, (unsigned long)_frozen]; +# if SENTRY_TARGET_PROFILING_SUPPORTED + [result appendFormat: + @"\nslowFrameTimestamps: %@\nfrozenFrameTimestamps: %@\nframeRateTimestamps: %@", + _slowFrameTimestamps, _frozenFrameTimestamps, _frameRateTimestamps]; +# endif // SENTRY_TARGET_PROFILING_SUPPORTED + return result; +} + @end #endif // SENTRY_UIKIT_AVAILABLE