ionic-team / ionic-portals Goto Github PK
View Code? Open in Web Editor NEWPortals Javascript Library and Docs
Home Page: https://ionic.io/docs/portals
License: Other
Portals Javascript Library and Docs
Home Page: https://ionic.io/docs/portals
License: Other
Dear ionic-team,
After using Portals successfully in production for multiple weeks, I noticed hundreds of NullPointerExceptions in my sentry.io crash-reports. Specifically, a NullPointerException happened in the following line:
https://github.com/ionic-team/ionic-portals/blob/main/android/IonicPortals/src/main/kotlin/io/ionic/portals/PortalFragment.kt#L99
Here is the stacktrace that was reported by sentry.io:
java.lang.NullPointerException: null
at io.ionic.portals.PortalFragment.load(PortalFragment.kt:99)
at io.ionic.portals.PortalFragment.onViewCreated(PortalFragment.kt:44)
at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:2987)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:546)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:282)
at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:112)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1647)
at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3128)
at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:3072)
at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:251)
at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:502)
at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:246)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1435)
at android.app.Activity.performStart(Activity.java:8231)
at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3853)
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2317)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8625)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
I suspect that this happens when a PortalFragment gets instantiated without an instance of the Portal-class.
For example, such erroneous instantiations might happen when the following empty default-constructor of a PortalFragment gets invoked:
https://github.com/ionic-team/ionic-portals/blob/main/android/IonicPortals/src/main/kotlin/io/ionic/portals/PortalFragment.kt#L27
This makes me question whether there is a potential problem with Fragment-recreations.
The Android-OS might destroy and recreate Fragments at any time, and this might trigger the NullPointerException.
Perhaps I could "fix" the bug by adding more null-checks to the problematic code, but my goal would be to find a root-cause instead of only adding null-checks.
Hi,
Clicking on the link to get a free registration key shows a 404 page.
I experienced this crash on a pet project I'm working on using ionic Portals. I have it when using a fragment that extends PortalFragment(but also happened in an activity that contains a portal in the layout). We use a library that internally does a call to startActivityForResult and the crash happens when the result is returned.
java.lang.NullPointerException
at io.ionic.portals.PortalFragment.load(PortalFragment.kt:99)
at io.ionic.portals.PortalFragment.onViewCreated(PortalFragment.kt:44)
at com.swisscom.myswisscom.activities.login.fragments.LoginFragment.onViewCreated(LoginFragment.kt:14)
at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:2987)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:546)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:282)
In order to avoid the crash I used the following code but I think this might go into a place inside the PortalFragment implementation
class LoginFragment : PortalFragment {
constructor() : super() {}
constructor(portal: Portal?) : super(portal) {}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
if (activity != null && portal!=null) {
super.onViewCreated(view, savedInstanceState)
setHasOptionsMenu(false)
}
}
I think the only check needed is the portal not being null
[!] Error installing IonicLiveUpdates
[!] /usr/bin/git clone https://github.com/ionic-team/live-updates-sdk.git /var/folders/wp/yy92cy4j28q2m49vszqs4srm0000gn/T/d20220209-54213-1wln4g6 --template= --single-branch --depth 1
Cloning into '/var/folders/wp/yy92cy4j28q2m49vszqs4srm0000gn/T/d20220209-54213-1wln4g6'...
remote: Repository not found.
fatal: repository 'https://github.com/ionic-team/live-updates-sdk.git/' not found
I’ve been trying to build the Portals iOS framework from source (due to issues using Cocoapods with my ObjC project) but have come across this…
In ‘PortalWebView.swift on line 64:
‘class InternalCapWebView: CAPWebView {‘
This line fails as ‘CAPWebView’ cannot be found and I cannot see anywhere this is defined (in Portals or Capacitor). Am I missing something? (e.g. a specific Capacitor version).
I assume it must be something I'm doing wrong as you must be able to build it there. Any help would be greatly appreciated.
Calling reload on a loaded Portal Fragment after the Live Updates web assets are removed should redirect back to the web assets bundled with the app. This currently goes to an error page and requires the fragment to be reloaded fully to work.
Fix idea: do what happens on initial fragment load instead of a simple reload.
bridge?.setServerAssetPath(startDir)
From this website
After adding a capacitor dependency in your Podfile,
the instruction says the plugin should be registered in viewDidload()
override func viewDidLoad() {
// Inject the plugin into the native bridge
apiPlugin = bridge?.plugin(withName: "MyPlugin") as? MyPlugin
// now call super which will start the initial load
super.viewDidLoad()
}
But in the example e-com app link here
The project use "CapacitorCamera"
but it wasn't registered any where in all of the view model files
the only plugin registered is a local plugin
func handle(bridge: CAPBridgeProtocol?) {
subRef = PortalsPlugin.subscribe("dismiss") { [weak self] result in
if result.data as! String == "cancel" || result.data as! String == "success" {
DispatchQueue.main.async {
self?.shouldDisplayCheckout = false
}
}
}
apiPlugin = bridge?.plugin(withName: "ShopAPI") as? ShopAPIPlugin
apiPlugin?.dataProvider = coordinator.dataStore
apiPlugin?.actionDelegate = self
}
I think the plugins are auto registered like the one from the community plugins,
the website also stated this for the community plugins
Plugins are automatically registered on iOS.
So i guess the plugins are auto registered if they are installed by pod ?
Hi, I want to integrate ionic into native app and when I am in the page of ionic, I want to go to native again or to another h5 page, is there any way to do that?
Checked the sample of ecommerce-app and didn't find anything about it. Any suggestions or approaches? Thanks for your help!
Im using this gradle dependency: implementation("io.ionic:portals:0.5.0")
Gradle can compile build files but warns it missing dependecy to Cordova. I can however reference code from your lib.
When building app project, it fails, its complains about missing Cordova dependency.
> Could not resolve all files for configuration ':app:demoDebugRuntimeClasspath'.
> Could not find org.apache.cordova:framework:7.0.0.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/org/apache/cordova/framework/7.0.0/framework-7.0.0.pom
- https://repo.maven.apache.org/maven2/org/apache/cordova/framework/7.0.0/framework-7.0.0.pom
- https://maven.shortcut.io/org/apache/cordova/framework/7.0.0/framework-7.0.0.pom
Required by:
project :app > io.ionic:portals:0.5.0 > com.capacitorjs:core:3.4.1
Am i missing any other dependencies or?
Hi ionic team,
Our project is using ionic 3, cordova, Angular. I would like to know if we can use Portals, Our company is very interested in this feature: Micro Frontends with Module Federation, but did not find documentation and Demo for ionic Angular.
thanks!
Just testing an issue thing.
Following the QuickStart guides, it seems like in iOS the web content is expected to be a Capacitor app? The same built web app works for Android.
Here's the error in the Xcode console:
⚡️ ERROR: Unable to find application directory at: "file:///private/var/containers/Bundle/Application/6C3DFA39-02A0-4878-A78B-3C3D535AD9EE/PortalsDemo.app/public"!
Unable to find capacitor.config.json, make sure it exists and run npx cap copy.
Unable to find config.xml, make sure it exists and run npx cap copy.
2022-06-15 12:11:53.660581-0700 PortalsDemo[5584:383934] [ViewportSizing] maximumViewportInset cannot be larger than frame
2022-06-15 12:11:53.660622-0700 PortalsDemo[5584:383934] [ViewportSizing] minimumViewportInset cannot be larger than frame
⚡️ ERROR: Unable to load /private/var/containers/Bundle/Application/6C3DFA39-02A0-4878-A78B-3C3D535AD9EE/PortalsDemo.app/public
⚡️ This file is the root of your web app and must exist before
⚡️ Capacitor can run. Ensure you've run capacitor copy at least
⚡️ or, if embedding, that this directory exists as a resource directory.
Posting here for more visibility, as this is specifically related to Portal's itself.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.