fix(android,ios): prevent blur initialization delay and z-ordering bug#99
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe PR moves Android blur initialization from a delayed runnable to immediate inline calls, adjusts iOS AdvancedBlurView to insert hosting view at correct z-order and update hosting controller in place, and changes VibrancyEffectView to apply effects immediately then animate them off. Example app metadata/scripts are also updated. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@ios/Views/AdvancedBlurView.swift`:
- Around line 102-103: The new else path calls setupHostingController() too
early and bypasses the existing layoutSubviews() guard; instead of calling
setupHostingController() unconditionally in that branch, only initialize the
hosting controller when the view has non-zero bounds (e.g. check bounds.isEmpty
or width/height > 0) or defer by returning and letting layoutSubviews() call
setupHostingController(); update the branch around setupHostingController() so
it mirrors the layoutSubviews() gating to avoid initializing before first
layout.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 757f3331-5daf-4aac-ba46-1ebd70e11972
📒 Files selected for processing (2)
android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurView.ktios/Views/AdvancedBlurView.swift
| } else { | ||
| setupHostingController() |
There was a problem hiding this comment.
Keep the initial hosting-controller creation gated on non-zero bounds.
layoutSubviews() explicitly defers setupHostingController() until the view has a real frame, but this new else path bypasses that guard. Any prop update before first layout will now recreate the original “initialize too early” behavior the file is trying to avoid.
Suggested fix
private func updateView() {
if let hosting = hostingController {
// Update the existing controller's root view to avoid expensive recreation
// This fixes performance bottlenecks and state synchronization issues
let blurStyle = blurStyleFromString(blurTypeString)
let swiftUIView = BasicColoredView(
blurAmount: blurAmount,
blurStyle: blurStyle,
ignoreSafeArea: ignoreSafeArea,
reducedTransparencyFallbackColor: reducedTransparencyFallbackColor
)
hosting.rootView = swiftUIView
hosting.view.setNeedsLayout()
} else {
- setupHostingController()
+ guard bounds.width > 0 && bounds.height > 0 else { return }
+ setupHostingController()
}
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@ios/Views/AdvancedBlurView.swift` around lines 102 - 103, The new else path
calls setupHostingController() too early and bypasses the existing
layoutSubviews() guard; instead of calling setupHostingController()
unconditionally in that branch, only initialize the hosting controller when the
view has non-zero bounds (e.g. check bounds.isEmpty or width/height > 0) or
defer by returning and letting layoutSubviews() call setupHostingController();
update the branch around setupHostingController() so it mirrors the
layoutSubviews() gating to avoid initializing before first layout.
DanielAraldi
left a comment
There was a problem hiding this comment.
In iOS, the VibrancyView isn't working:

In Android, the build breaks:
Error: /Users/danielsaraldi/Documents/react-native-blur/example/android/gradlew app:assembleDebug -x lint -x test --configure-on-demand --build-cache -PreactNativeDevServerPort=8081 -PreactNativeArchitectures=arm64-v8a exited with non-zero code: 1
DanielAraldi
left a comment
There was a problem hiding this comment.
LGTM!
Android works, I have cleaned it, and it works haha 😂
I was going to ask you to clean the cache xD perfect!!! 👌 |
On Android, remove the deferred runnable that caused a 1-second delay artifact and initialize blur immediately in onAttachedToWindow.
On iOS, ensure the blur view is inserted at index 0 to stay behind content, and update the existing hosting controller's root view instead of recreating it to fix performance and state sync issues.
Summary by CodeRabbit
Bug Fixes
Performance Improvements
Chores