Comments (11)
kotlinx-coroutines-swing
should go in jvmMain/desktopMain dependecies block.
from compose-multiplatform.
Hi @luanrodrigsr
I confirm that this is a bug in Lifecycle implementation for desktop target.
The good news is that it is already fixed, however, the fix is not yet published.
I tried your snippet on the newer version and it now works.
Currently, I would expect it to be available Lifecycle 2.8.0-rc01 release and the subsequent Compose 1.6.10-rc01 release.
from compose-multiplatform.
Oh. I tried both of them, separately. Not at the same time.
I am using desktopMain right now, by the way.
Ah ok sorry I misunderstood you. Can you post the errors you are getting
from compose-multiplatform.
The code after the lifecycleRegistry.currentState = Lifecycle.State.CREATED
line is not being executed. Which is preventing the "Application" for being created. It only happens when i use the kotlinx-coroutines-swing
dependency.
But, when i updated the code on line 75 to LifecycleRegistry.createUnsafe(this)
, it works fine. (Pay attention to the debug panel which shows the enforceMainThread
field set to false
. Looking at the source code, this parameter is present in the private constructor of the LifecycleRegistry
, that is (i believe) supposed to be always true
).
The documentation says that the method createUnsafe
:
Creates a new LifecycleRegistry for the given provider, that doesn't check that its methods are called on the threads other than main. LifecycleRegistry is not synchronized: if multiple threads access this LifecycleRegistry, it must be synchronized externally.
Considering all this, I may not be fully aware of the implications that using the createUnsafe
method can bring. Except for the fact that "if multiple threads access this LifecycleRegistry
, it must be synchronized externally".
from compose-multiplatform.
I see, Humm 🤔 seems like a problem inside LifecycleRegistry constructor. You are basically having a silent crash or so.
It is hard to predict with logs or more information. I would start by checking the implementation of LifecycleRegistry.
from compose-multiplatform.
Hey @pablichjenkov, thanks! I updated my build.gradle.kts
files, but still couldn't get the code to work.
from compose-multiplatform.
I think you misunderstood my previous comment. You have either jvmMain or desktopMain not both. Need to add swing dependecy in one of them. Are you using jvmMain or desktopMain?
from compose-multiplatform.
Oh. I tried both of them, separately. Not at the same time.
I am using desktopMain right now, by the way.
from compose-multiplatform.
To add more context, what I'm trying to achieve is to create a custom implementation of the LifecycleOwner
interface in an abstract Application class that will be responsible for controlling the lifecycle of the desktop app (outside of compose). I needed to add the kotlinx-coroutines-swing
dependency because of the "Module with the Main dispatcher is missing" (#4653) error.
from compose-multiplatform.
Thank you. I will try to dig into the implementation.
I just wanna note that the enforceMainThread
being set to false
on the example i gave is working as intended, I think, since it is the role of the createUnsafe
method.
This makes me wonder if the right way to create a LifecycleRegistry, in my case, wasn't using the public constructor which sets this field to true
. I am just too worried about the inability to do so. I mean, the lifecycle registry is created, but I'm unable to interact with it.
from compose-multiplatform.
Thank you! @kropp
from compose-multiplatform.
Related Issues (20)
- Compose 1.6.2 iOS ComposeContainer memory leak HOT 2
- ComposeUIViewController don't Update View HOT 2
- TextField cannot input in ExposedDropdownMenuBox, when ExposedDropdownMenu is expanded HOT 4
- 🚀 Low-code tools to speed up and ease app development HOT 1
- java.lang.SecurityException: SHA-256 digest error for org/bouncycastle/operator/OperatorCreationException.class HOT 3
- [IOS-Simulator] TextField Text Cursor Jumps Around After Using CMD+A then Delete to clear all text preventing further text input.
- Using `ComposeScene`s with anything but `MainUIDispatcher` results in a deadlock HOT 19
- Generate XCFramework with UI, resources and dependencies HOT 2
- Remove compose ui fallback from LocalViewModelStoreOwner HOT 3
- Kotlin/Wasm responsive layout HOT 7
- Support text hyphenation HOT 1
- How to monitor finger position like touch_down\touch_move on Android platform?
- Brush.linearGradient don't work HOT 1
- Order of accessibility nodes is wrong HOT 1
- When targeting Android for a KMP project using `Coil 3.0.0-alpha06`, attempting to use `.toBitmap()` and `.asComposeImageBitmap()` results in `Unresolved reference` HOT 2
- Consider removing `Unconfined` dispatcher as default `CoroutineContext` for `ComposeScene` creation HOT 1
- Consider adding a boolean to disable `GlobalSnapshotManager.ensureStarted()` call during scene creation
- PressInteraction.Cancel is sent on mouse press and drag outside surface HOT 1
- Are there any good suggestions about using compose to generate UI through drag and drop and output the code to the local? HOT 5
- Erratic window focus behavior HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compose-multiplatform.