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

Versioning - #3

Closed
dxNeil opened this issue Jan 22, 2017 · 66 comments
Closed

Versioning - #3

dxNeil opened this issue Jan 22, 2017 · 66 comments
Labels

Comments

@dxNeil
Copy link

dxNeil commented Jan 22, 2017

When downloading from Mojang, CurseCDN and BCML,

It gives me errors because it doesn't download properly. Incomplete handshakes.

HCMLSoft is the only source that works. It is not updated to 1.11.0/1.11.2.

@huanghongxun
Copy link
Collaborator

please update to 2.6

@dxNeil
Copy link
Author

dxNeil commented Jan 23, 2017

Thanks for getting back to me huanghongxun,

I have cloned it, and imported your project with gradle on Eclipse. Is it possible that we can update our launcher code so it supports 2.6 and those sources and 1.11.x works?

Do you have a donation address? We would like to donate to you once our launcher gets up and running (over 300K downloaders in our community!)

@huanghongxun
Copy link
Collaborator

Now I even doubt that where you are from...
It's quite clear that you are supposed to use Netbeans instead of Eclipse because I've used the swing designer, or you will not stand the code generated automatically.
The donation address has been removed because of some reasons.

@dxNeil
Copy link
Author

dxNeil commented Jan 23, 2017 via email

@dxNeil
Copy link
Author

dxNeil commented Jan 23, 2017

Please, it doesn't work on Netbeans, gradle errors.

Eclipse, it can run perfectly.

How to update the code to 2.6?

@dxNeil
Copy link
Author

dxNeil commented Jan 23, 2017

NetBeans Gradle Errors:

"Issue 1

"

@dxNeil
Copy link
Author

dxNeil commented Jan 24, 2017

If you help me get 2.6 into eclipse, and if it downloads ALL update from mojang perfectly, I will pay you 300+ CNY (Chinese currency) through bitcoin or paypal.

Please if you help, I'll be grateful :)

@huanghongxun
Copy link
Collaborator

It seems that your gradle installation is broken.
Clean up your environment and just install Netbeans and then its plugin Gradle Support(this plugin will automatically install gradle). A brand new env. should work.
There's nothing special to the code.

@dxNeil
Copy link
Author

dxNeil commented Jan 24, 2017

I have deleted the netbeans projects, reinstalled netbeans, and installed Gradle support -

Issue 1

@huanghongxun
Copy link
Collaborator

It seems that there are some compilation errors.
show the screenshot when you click the build button.

@dxNeil
Copy link
Author

dxNeil commented Jan 25, 2017

image
image

@huanghongxun
Copy link
Collaborator

now please pull and retry.

@dxNeil
Copy link
Author

dxNeil commented Jan 25, 2017

Yes sir, I will do it right now and let you know immediately

@dxNeil
Copy link
Author

dxNeil commented Jan 25, 2017

Thank you very much. It works beautifully. I hope to see you soon, let me know when you open BTC donations.

Sincerely,

The DeviantsMC Team (http://deviantsmc.com)

@huanghongxun
Copy link
Collaborator

Donation address, paypal [email protected]

@dxNeil
Copy link
Author

dxNeil commented Jan 25, 2017

Hi I prefer to use BTC because of privacy reasons, do you have a BTC address?

I don't think the assets download properly though from Mojang. Thanks anyways for helping

image

@huanghongxun
Copy link
Collaborator

Fixed in a recent commit.
Because Mojang closed SSL channel to asset download site.

@dxNeil
Copy link
Author

dxNeil commented Jan 26, 2017

Hi, thanks we've updated our code base.

We will donate 70CNY tomorrow (Australian time) for your good work.

Just wondering though, when downloading from Mojang, it always gets stuck at 99- 6/7 jobs will never complete. Do you know why?

Picture #1 - http://prnt.sc/e0ibbz
Picture #2 - http://prnt.sc/e0i6k8
Picture #3 - http://prnt.sc/e0i5n4

@huanghongxun
Copy link
Collaborator

It would be a network problem?
So it finally failed because time limit exceeded?
Here it could finish all downloads.
Please try to copy links and download them by web browser to check if it's really network problem.

@dxNeil
Copy link
Author

dxNeil commented Jan 26, 2017

It works on web browser. The internet is good, and fast. I have tried on BMCL as source, and it works.

@dxNeil
Copy link
Author

dxNeil commented Jan 26, 2017

This is one method I use to fix it, disposing the TaskWindow when the percentage hits 99

image

But it is very dangerous... If a new version is installed/other mod is installed it might cause a corruption, right?

@dxNeil
Copy link
Author

dxNeil commented Jan 27, 2017

Can you put up a donation page? Or a paypal link for me to donate with my card? (I don't use paypal) I have a card

@huanghongxun
Copy link
Collaborator

Those download jobs which cannot finish may not be ignored.
And when downloading libraries, and the progress reach 99%, and the last download job could finish, your code will break the downloading and cause game crashed because the libraries are not complete.
Please see the stacktrace when those tasks(in the screenshots you gave) failed.

@dxNeil
Copy link
Author

dxNeil commented Jan 27, 2017

There is no stack trace. It doesn't say failed. It just stays on 99% and PGS = ??? for ever.

image

@huanghongxun
Copy link
Collaborator

So none of them failed?

@huanghongxun
Copy link
Collaborator

And could you check the lang file(https://github.com/huanghongxun/HMCL/blob/master/HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang/I18N_en.lang)?
I think there are a great number of grammar and spelling mistakes.

And I found it difficult to create a paypal donation link and BTC link because of their authentication.

@dxNeil
Copy link
Author

dxNeil commented Jan 27, 2017

None failed.

No stacktrace or error or any fail in console.

For example: resource /50/50a59a.... is a task that is executed, but not finished not failed. Just idle

@dxNeil
Copy link
Author

dxNeil commented Jan 27, 2017

Okay no problem. I will get around to donate to you soon. I run a bitcoin mining pool. I will cash out and convert it to your paypal instead during the monthly pay date.

I'll check the language file.

@huanghongxun
Copy link
Collaborator

And when you use other minecraft launchers would this problem arise again?
Chinese network should be worse than Australian.

@dxNeil
Copy link
Author

dxNeil commented Jan 27, 2017

image

Breakpoint set at every line on url.openConnection

@huanghongxun
Copy link
Collaborator

huanghongxun commented Jan 27, 2017

You should click "Debug" Button(or Ctrl+F5) to get into debug mode.

@huanghongxun
Copy link
Collaborator

And you should delete CrashReporter.java to stop your app send crash report to my server.

@dxNeil
Copy link
Author

dxNeil commented Jan 27, 2017

I emptied the reportToServer method
image

Nothing diagnosed to far

image

@huanghongxun
Copy link
Collaborator

huanghongxun commented Jan 27, 2017

So you set some breakpoints and run the app and the application even not run to these places?incredible...
test TaskList?

You should keep breakpoints enabled when app run from beginning to end.
And you needn't clean up folder assets each time when debugging, just let these unfinished tasks do.
Maybe you enable these breakpoints after the progress reached 99%?

@dxNeil
Copy link
Author

dxNeil commented Jan 27, 2017

First test, I ran from start to finish.

Second test I enabled breakpoints 98.

Do you think changing the buffersize array will fix this? I think it won't because I set it to double and it didn't do a thing.

Anyway,

I have tested TaskList
image

It just stops at 99.

Another image:
image

also

I did this one again:
Uploading image.png…

@huanghongxun
Copy link
Collaborator

Anyway, do you keep these breakpoints enabled from start to finish?
Whatever the problem is, It should run to FileDownloadTask.executeTask().
I guess you enable these breakpoints after these tasks idled.

Or it may be a nasty problem and I may not solve it.......

@dxNeil
Copy link
Author

dxNeil commented Jan 27, 2017

If I keep the break points from start to finish, it would take many, possibly thousands of clicks on the green button right to get from start to finish, right?

@huanghongxun
Copy link
Collaborator

No, when you start a new test, you need not clean up assets folder, just let these unfinished tasks do.
When you retry download assets, these unfinished tasks will be executed again.
So when application first paused, it would be the unfinished task's FileDownloadTask.


Things I mentioned above is better than that below.

Or you could make a trick, add codes like this:

if (url.endsWith("xxxxx")) {
System.out.println(); // make a breakpoint here.
}

make xxxxx the unfinished asset file name like: 4f8c3f9b4f290f63c78bf3bbaad16906a3ccff29

@dxNeil
Copy link
Author

dxNeil commented Jan 27, 2017

Yeah, that's what I've been doing. I delete other folders like libraries, but I keep 'assets' because I want it to start downloading from there.

I will try your new trick solution.

@dxNeil
Copy link
Author

dxNeil commented Jan 27, 2017

Is this correct?

image

@huanghongxun
Copy link
Collaborator

huanghongxun commented Jan 27, 2017

Yes.
And it seems the connection has been successfully created.
please click 'step over' button to run by each line.
and see which line block the app.

But I think it may not happen if reading bytes blocks app.

@dxNeil
Copy link
Author

dxNeil commented Jan 27, 2017

image

I put some breakpoints on this. How do I figure out which line would cause it?

@dxNeil
Copy link
Author

dxNeil commented Jan 27, 2017

image

I am pressing the step over button 100s of times, it is still stuck on 17%

@dxNeil
Copy link
Author

dxNeil commented Jan 27, 2017

I will try again using an autoclicker I will click from 80%

@huanghongxun
Copy link
Collaborator

huanghongxun commented Jan 27, 2017

Look! when you started debugging, these tasks began downloading and the progress is not '???' but 1%.
But in normal mode, them stayed at '???'.
The problem has become clearer.

@dxNeil
Copy link
Author

dxNeil commented Jan 27, 2017

image
I did another test with an autoclicker to click the step over button 1000s of times, it stopped at 97% those ??? PGs are there. It stopped on that line.

That line says "Program counter disabled at a breakpoint"

@huanghongxun
Copy link
Collaborator

You could leave these unfinished tasks and pause the app by the trick and when the progress reach 1%, disable these breakpoints and click continue button and see if these tasks could successfully finish.
If it do, I guess it's ISP's problem. Too fast network connection cause some problems.

@dxNeil
Copy link
Author

dxNeil commented Jan 27, 2017

The step button ALWAYS stops on this line:
image

@huanghongxun
Copy link
Collaborator

huanghongxun commented Jan 27, 2017

You could leave these unfinished tasks and pause the app by the trick and when the progress reach 1%, disable these breakpoints and click continue button and see if these tasks could successfully finish.

You needn't make so many breakpoints... just make some necessary ones and click 'step over' to step over each line.

It seems that you have not used IDE debugging tools before, even Eclipse.

@dxNeil
Copy link
Author

dxNeil commented Jan 27, 2017

EDIT: merged below

@dxNeil
Copy link
Author

dxNeil commented Jan 27, 2017

Can you tell me which of these lines to put breakpoints on:

HttpURLConnection connection = (HttpURLConnection) url.openConnection();

            connection.setConnectTimeout(5000);
            connection.setRequestProperty("User-Agent", "Hello Minecraft!");

            // Connect to server.
            connection.connect();
            
            // Make sure response code is in the 200 range.
            if (connection.getResponseCode() / 100 != 2)
                throw new NetException(C.i18n("download.not_200") + " " + connection.getResponseCode());

            // Check for valid content length.
            int contentLength = connection.getContentLength();
            if (contentLength < 1)
                throw new NetException("The content length is invalid.");

            filePath.getParentFile().mkdirs();

            File tempFile = new File(filePath.getAbsolutePath() + ".hmd");
            if (!tempFile.exists())
                tempFile.createNewFile();
            else if (!tempFile.renameTo(tempFile)) // check file lock
                throw new IllegalStateException("The temp file is locked, maybe there is an application using the file?");

            // Open file and seek to the end of it.
            file = new RandomAccessFile(tempFile, "rw");

            MessageDigest digest = DigestUtils.getSha1Digest();

            stream = connection.getInputStream();
            int lastDownloaded = 0;
            downloaded = 0;
            long lastTime = System.currentTimeMillis();
            while (true) {
                // Size buffer according to how much of the file is left to download.
                if (!shouldContinue) {
                    closeFiles();
                    filePath.delete();
                    break;
                }

                byte buffer[] = new byte[MAX_BUFFER_SIZE];

                // Read from server into buffer.
                int read = stream.read(buffer);
                if (read == -1)
                    break;

                digest.update(buffer, 0, read);

                // Write buffer to file.
                file.write(buffer, 0, read);
                downloaded += read;

                long now = System.currentTimeMillis();
                if (ppl != null && (now - lastTime) >= 1000) {
                    ppl.setProgress(this, downloaded, contentLength);
                    ppl.setStatus(this, (downloaded - lastDownloaded) / 1024 + "KB/s");
                    lastDownloaded = downloaded;
                    lastTime = now;
                }
            }
            closeFiles();
            if (aborted)
                tempFile.delete();
            else {
                if (filePath.exists())
                    filePath.delete();
                tempFile.renameTo(filePath);
            }
            
            if (!shouldContinue)
                break;
            if (downloaded != contentLength)
                throw new IllegalStateException("Unexptected file size: " + downloaded + ", expected: " + contentLength);
            String hashCode = String.format("%1$040x", new Object[] { new BigInteger(1, digest.digest()) });
            if (expectedHash != null && !expectedHash.equals(hashCode))
                throw new IllegalStateException("Unexpected hash code: " + hashCode + ", expected: " + expectedHash);

            if (ppl != null)
                ppl.onProgressProviderDone(this);
            return;
        } catch (IOException | IllegalStateException | NetException e) {
            setFailReason(new NetException(C.i18n("download.failed") + " " + url, e));
        } finally {
            closeFiles();
        }
    }
    if (failReason != null)
        throw failReason;

select the lines with bold

Also, I don't normally use netbeans. But what do you mean about:

When the progress reaches 1%. So you mean 1% left? When it reaches 99%?

@dxNeil
Copy link
Author

dxNeil commented Jan 27, 2017

Btw, I tried your pausing method

Didn't work

image

@dxNeil
Copy link
Author

dxNeil commented Jan 27, 2017

The if(url.endsWith("xxx")) trick won't work, those URLs are always different.

@dxNeil
Copy link
Author

dxNeil commented Jan 27, 2017

I am retesting it now,

image

I paused it, waited two minutes, unpaused it, and nothing happened. Still PGS = ???

@dxNeil
Copy link
Author

dxNeil commented Jan 28, 2017

image

I set that to 6 instead of 64 and now it works.

Mojang limits how much content can be downloaded in x amount of seconds. I think having a thread.sleep(3000) also every 5 seconds when downloading will help.

I will get that German translation for you shortly.

@huanghongxun
Copy link
Collaborator

huanghongxun commented Jan 29, 2017

It works? So why could I download these things properly..?
Could it be that I am in China?

I see, this could explain why you paused the application then continued it and these downloads could 'come to life again'.

Thanks for your work and translations.

@dxNeil
Copy link
Author

dxNeil commented Jan 29, 2017

No problem. I believe this is because the ExecutorService threadpool uses 64 threads. Many minecraft launchers only use 8.

Due to the high amount of threads, many downloads happen at once.
I think Mojang restrict the amount of connections/downloads per second.

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

No branches or pull requests

2 participants