Skip to content

Commit

Permalink
fix(ios): fcp record of performance api may not working
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwcg committed Nov 14, 2024
1 parent 47d5937 commit caafb10
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
11 changes: 8 additions & 3 deletions renderer/native/ios/renderer/HippyUIManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ HIPPY_EXTERN NSString *const HippyFontChangeTriggerNotification;
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;

/// Get all rootView
- (NSArray<__kindof UIView *> *)rootViews;

/// Get rootView with given tag
/// Note: this is root's contentView,
/// NOT the HippyRootView instance!
- (UIView *)rootContentViewForTag:(NSNumber *)rootTag;

/// Gets the view associated with a hippyTag.
/// - Parameters:
/// - hippyTag: NSNumber
Expand Down Expand Up @@ -129,9 +137,6 @@ HIPPY_EXTERN NSString *const HippyFontChangeTriggerNotification;
/// - Parameter tag: root tag
- (void)setNeedsLayoutForRootNodeTag:(NSNumber *)tag;

/// Get all rootView
- (NSArray<__kindof UIView *> *)rootViews;

/// Update view with props
- (void)updateView:(NSNumber *)componentTag onRootTag:(NSNumber *)rootTag props:(NSDictionary *)pros;

Expand Down
5 changes: 5 additions & 0 deletions renderer/native/ios/renderer/HippyUIManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ - (void)domNodeForComponentTag:(int32_t)componentTag
}
}

- (UIView *)rootContentViewForTag:(NSNumber *)rootTag {
AssertMainQueue();
return [_viewRegistry rootComponentForTag:rootTag];
}

- (UIView *)viewForHippyTag:(NSNumber *)hippyTag onRootTag:(NSNumber *)rootTag {
AssertMainQueue();
return [_viewRegistry componentForTag:hippyTag onRootTag:rootTag];
Expand Down
11 changes: 8 additions & 3 deletions renderer/native/ios/renderer/component/view/UIView+MountEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@
*/

#import "UIView+MountEvent.h"
#import "objc/runtime.h"
#import "HippyUIManager.h"
#import "UIView+Hippy.h"
#import "UIView+Render.h"
#import "HippyRootView.h"
#import "HippyBridge+PerformanceAPI.h"
#import <objc/runtime.h>


/// The FCP Notification Imp
const NSNotificationName HippyFirstContentfulPaintEndNotification = @"HippyFirstContentfulPaintEndNotification";
Expand Down Expand Up @@ -95,8 +98,10 @@ - (void)viewDidUnmoundEvent {

- (void)sendAttachedToWindowEvent {
if (HippyPaintTypeFCP == self.paintType) {
HippyRootView *rootView = (HippyRootView *)[self hippyRootView];
[rootView sendFCPNotiIfNeeded:self];
NSNumber *rootTag = [self rootTag];
HippyUIManager *uiManager = [self uiManager];
UIView *rootContentView = [uiManager rootContentViewForTag:rootTag];
[(HippyRootView *)rootContentView.superview sendFCPNotiIfNeeded:self];
}
if (self.onAttachedToWindow) {
self.onAttachedToWindow(nil);
Expand Down

0 comments on commit caafb10

Please sign in to comment.