Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[iOS] Add last page info. (#2918)
Browse files Browse the repository at this point in the history
  • Loading branch information
wqyfavor authored and jianhan-he committed Sep 18, 2019
1 parent 4ce90b0 commit 5499154
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,12 @@ typedef enum : NSUInteger {
*/
- (void)setViewportWidth:(CGFloat)width;

/**
* @abstract Get information about the last rendered page.
Useful fot debugging and fixing online bugs.
*/
+ (NSDictionary*)lastPageInfo;

/**
* Deprecated
*/
Expand Down
21 changes: 21 additions & 0 deletions ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@

NSTimeInterval JSLibInitTime = 0;

static NSString* lastPageInfoLock = @"";
static NSDictionary* lastPageInfo = nil;

typedef enum : NSUInteger {
WXLoadTypeNormal,
WXLoadTypeBack,
Expand Down Expand Up @@ -316,6 +319,11 @@ - (void)renderWithURL:(NSURL *)url options:(NSDictionary *)options data:(id)data
return;
}
WXLogInfo(@"pageid: %@ renderWithURL: %@", _instanceId, url.absoluteString);

@synchronized (lastPageInfoLock) {
lastPageInfo = @{@"pageId": [_instanceId copy], @"url": [url absoluteString] ?: @""};
}

[WXCoreBridge install];
if (_useBackupJsThread) {
[[WXSDKManager bridgeMgr] executeJSTaskQueue];
Expand All @@ -339,6 +347,10 @@ - (void)renderView:(id)source options:(NSDictionary *)options data:(id)data
_options = [options isKindOfClass:[NSDictionary class]] ? options : nil;
_jsData = data;
WXLogInfo(@"pageid: %@ renderView pageNmae: %@ options: %@", _instanceId, _pageName, options);

@synchronized (lastPageInfoLock) {
lastPageInfo = @{@"pageId": [_instanceId copy], @"options": options ? [options description] : @""};
}

[WXCoreBridge install];
if (_useBackupJsThread) {
Expand Down Expand Up @@ -1141,6 +1153,15 @@ - (void)didDisappear
}
}

+ (NSDictionary*)lastPageInfo
{
NSDictionary* result;
@synchronized (lastPageInfoLock) {
result = [lastPageInfo copy];
}
return result;
}

@end

@implementation WXSDKInstance (Deprecated)
Expand Down

0 comments on commit 5499154

Please sign in to comment.