Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

retrofit or okhttp get stuck #269

Closed
s949492225 opened this issue Jan 13, 2021 · 17 comments
Closed

retrofit or okhttp get stuck #269

s949492225 opened this issue Jan 13, 2021 · 17 comments
Assignees

Comments

@s949492225
Copy link

i use retrofit/okhttp3
if it run on idea,it work fine,
bug package exe or dmg,open it will get stuck.

i fire retrofit on Thread,and callback on awt javax.swing.SwingUtilities.invokeLater

this is my key code:
image
image

@s949492225
Copy link
Author

it get stuck on button click and click will fire retrofit call

@s949492225
Copy link
Author

All version have this bug,you can try it

@kirill-grouchnikov
Copy link

This will probably need to be rewritten using coroutines instead. And screenshots with code are better replaced with the code itself, ideally something that is small and standalone so that it can be debugged.

@s949492225
Copy link
Author

Coroutines or Thread shouldn't matter,
Debug is ok,But package release is not work ,
Deubg and Release may be something different.

@s949492225
Copy link
Author

s949492225 commented Jan 13, 2021

This is a simple demo to test.

import androidx.compose.desktop.Window
import androidx.compose.material.Text
import androidx.compose.material.Button
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import okhttp3.*
import java.io.IOException
import java.nio.charset.StandardCharsets

fun main() = Window {
    var text by remember { mutableStateOf("request url") }

    MaterialTheme {
        Button(onClick = {
            val client = OkHttpClient()
            val request = Request.Builder()
                .url("http://www.github.com")
                .build()
            client.newCall(request).enqueue(object : Callback {
                override fun onFailure(call: Call, e: IOException) {
                }

                override fun onResponse(call: Call, response: Response) {
                    text = String(response.body!!.bytes(), StandardCharsets.UTF_8)
                }
            })

        }) {
            Text(text)
        }
    }
}
implementation("com.squareup.okhttp3:okhttp:4.9.0")

@s949492225
Copy link
Author

Release will get stuck

@s949492225
Copy link
Author

You can try to make it work fine,Maybe I have a problem with it

@olonho
Copy link
Contributor

olonho commented Jan 13, 2021

Please try to log, if exception is thrown, it could be result of some library not included into native library.

@s949492225
Copy link
Author

Just get stuck,no log,no exception.

@AlexeyTsvetkov
Copy link
Collaborator

@s949492225 could you try adding modules("jdk.crypto.ec") to the nativeDistributions block? Does it help?

compose.desktop {
    application {
        mainClass = "MainKt"
        nativeDistributions {
            modules("jdk.crypto.ec")

            targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
            packageName = "untitled"
        }
    }
}

@s949492225
Copy link
Author

no,not work

@olonho
Copy link
Contributor

olonho commented Feb 2, 2021

Without additional info it's hard to debug this issue.

@s949492225
Copy link
Author

demo is here,just try it

@AlexeyTsvetkov
Copy link
Collaborator

I am not able to reproduce the issue with:

  • the sample above;
  • Compose Desktop 0.3.0 build;
  • modules("jdk.crypto.ec") added;

@s949492225 I've created a repo with the sample, can you try it to see if the issue still reproduces?
https://github.com/AlexeyTsvetkov/compose-okhttp-issue-sample

@s949492225
Copy link
Author

Compose Desktop 0.3.0 work fine;
Thanks @AlexeyTsvetkov;

AlexeyTsvetkov added a commit that referenced this issue Jul 19, 2021
Without this module most of https
is not going to work (see #269 or #429)

The inclusion of this module increases a size of
a prepackaged app by ~440 kb
and of a packaged dmg by ~167 kb
AlexeyTsvetkov added a commit that referenced this issue Jul 19, 2021
Without this module most of https
is not going to work (see #269 or #429)

The inclusion of this module increases a size of
a prepackaged app by ~440 kb
and of a packaged dmg by ~167 kb
mareklangiewicz pushed a commit to mareklangiewicz/compose-jb that referenced this issue Feb 14, 2022
Without this module most of https
is not going to work (see JetBrains#269 or JetBrains#429)

The inclusion of this module increases a size of
a prepackaged app by ~440 kb
and of a packaged dmg by ~167 kb
@ovitrif
Copy link

ovitrif commented Mar 11, 2022

Doesn't work for me, even with modules("jdk.crypto.ec") which is probably no longer needed in version 1.1.0

@okushnikov
Copy link
Collaborator

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants