Code Monkey home page Code Monkey logo

Comments (12)

Over17 avatar Over17 commented on June 28, 2024

Hi!

I think what you are observing is: https://forum.unity.com/threads/apk-with-expansion-file-obb-fails-to-load-the-second-scene-until-the-phone-has-been-restarted.465714/

The thread has quite comprehensive analysis of what's going on.

Your behavior is most likely because of the app not being able to access the OBB. The scene is becoming pink because of shaders missing; why did they end up in the OBB - that's another question - more details available here https://docs.unity3d.com/Manual/android-OBBsupport.html

The OBB is being mounted very early (before the engine is initialized), so the plugin is unable ask the user for the permission before the OBB has to be loaded.

The OBB is also mounted in onResume().

So, there's nothing with the plugin which corrupts your game. :)

Possible solutions:

  • get rid of the OBB. The most radical and the best solution. Try utilizing asset bundles instead.
  • ask for READ_EXTERNAL_STORAGE permission as soon as possible, and make Unity somehow pause and resume (show another activity? for a second) - it should make OBB loaded and fix all your issues.

Hope that helps.
Yury

from unityandroidpermissions.

MyOwnClone avatar MyOwnClone commented on June 28, 2024

Hi, thanks for the response,

I think what you are observing is: https://forum.unity.com/threads/apk-with-expansion-file-obb-fails-to-load-the-second-scene-until-the-phone-has-been-restarted.465714/

I think this is not the case, because our second scene actually loads and we are able to get even to any other scene, which is in OBB. We are able to get past menus to the actual game, where all the non-alpha assets are visible and game runs. Just the alpha based assets and UI is pink/corrupted.

As for possible solutions:

  • I am told that getting rid of the OBB is not option for us, as the asset bundles would be much more work and time for us, which we do not have
  • ask for READ_EXTERNAL_STORAGE - how do you mean it? We have it in our manifest, so you mean asking for the permission via the plugin? And than, after granting, doing pause and resume?

Thanks a lot,
Tom

from unityandroidpermissions.

Over17 avatar Over17 commented on June 28, 2024

Okay let's put it this way then:

  • in Unity Editor, disable "Split Application Binary", Build&Run - does it work?
  • in Unity Editor, enable "Split Application Binary", Build&Run - does it work?
  • install the game to an affected device from Google Play - does it work?
    -- if it doesn't, restart the device completely and run the game again - does it work?

Is there anything in the logcat when the game is not working correctly?

from unityandroidpermissions.

MyOwnClone avatar MyOwnClone commented on June 28, 2024

OK, it seems that we have solved it. Or "solved" it, I should say. In friday, I've made an experimental version without usage of the plugin for getting and setting the rights and handling our use case differently. But back then, we had to push it to our testers that are located off site, so in the mean time, I have reported the issue here.

We've just got report from our testers, that by removing the usage of the plugin, we've got rid of the pink/corrupted screen issue completely.

So, this seems to be related to the plugin somehow, as by simply removing it, the issue goes away. And the original issue, that the plugin should solve, we've resolved differently - by trying to load scene that should be on OBB and if it fails, asking user to allow the permission manually and restart the app.

Our case is (maybe) solved, but this does not solve the plugin issue itself.

As for the suggestion about restart, you've mentioned: no, restart did not help in any of the case. Only upgrade of Android OS. Also, we've had two devices - both Galaxy S6 edge model, one with Android 6 and one with 7. Problem occured when getting from Google Play on the 6 OS device, but not on the 7 OS device...

As for the rest of the suggestions, I haven't tried the "Split binary" option yet, but if you insist on that and if it would help you in development/bugfixing, I can try that too even when our case is somehow solved.

from unityandroidpermissions.

Over17 avatar Over17 commented on June 28, 2024

I'm happy that it work for you - too bad you are still thinking it's the plugin. I'm quite sure it's not the plugin causing the issue, rather it's a missing permission, most likely the READ_EXTERNAL_STORAGE. Maybe it's being asked too late. Unfortunately the details you posted here are not enough to find the root cause of the issue.

The "Split application binary" option is "enable/disable the OBB".

from unityandroidpermissions.

MyOwnClone avatar MyOwnClone commented on June 28, 2024

I am not saying that it is the plugin and I am blaming no one:-) It just occured to me as the most plausible explanation. It would be strange if managed code plugin caused this and broke the engine so badly, so if you're saying it is not the case, I believe you.

As for the READ_EXTERNAL_STORAGE, we have it in the manifest and had it there all the time... so I presume you mean we should ask for it via the plugin? And should we ask for the WRITE_EXTERNAL_STORAGE too? Because we have asked for WRITE_EXTERNAL_STORAGE and by using the plugin to ask for it, it has caused us the pink screen issue in the first place...

from unityandroidpermissions.

Over17 avatar Over17 commented on June 28, 2024

Let me try to explain it.

You have READ_EXTERNAL_STORAGE in the manifest.

Without the plugin, Unity asks for all the permissions on very first startup, early before the engine is initialized. If the user grants the permission, everything works fine.

With the plugin, a special flag is added to the manifest to suppress this dialog. Instead, you have to call an API to request a permission. Unfortunately, you can call into this API only after the engine is initialized; at this point the OBB had already been mounted, or not failed to mount because of a missing permission. The OBB mount failure usually happens on buggy devices when installing from Google Play, or devices prior to API 19 (Android 4.4).

The few ways known to me to workaround the OBB mount failure because of a missing permission are restarting the device, or pausing/resuming the activity AFTER the user has clicked "accept" in the permission dialog.

The issue is not present when you install the OBB by doing "build&run" in the Unity Editor, or when the OBB is disabled ("Split application binary" turned off).

It could be that you are facing a completely different issue; however, I haven't heard anything like that yet. In that case, if you could at least share your logcat (development version preferred) - would be helpful.

from unityandroidpermissions.

MyOwnClone avatar MyOwnClone commented on June 28, 2024

Hi, thanks again for clarification, much appreciated...

As for your answers:

Unfortunately, you can call into this API only after the engine is initialized; at this point the OBB had already been mounted, or not failed to mount because of a missing permission.

This is the thing I do not understand, because our testers reported that they were able to get into game and into all the other scenes. But all the alpha textures and UI were wrong. Maybe the reports are wrong.

pausing/resuming the activity AFTER the user has clicked "accept" in the permission dialog.

Ok, this is valuable insight. So if I understand correctly, Unity will try to mount the OBB again in this case?

The issue is not present when you install the OBB by doing "build&run" in the Unity Editor, or when the OBB is disabled ("Split application binary" turned off).

Yes, this is true.

As for the logcat output, I will try to tell our testers to get it from affected device...

from unityandroidpermissions.

Over17 avatar Over17 commented on June 28, 2024

Ok, this is valuable insight. So if I understand correctly, Unity will try to mount the OBB again in this case?

Correct.

This is the thing I do not understand, because our testers reported that they were able to get into game and into all the other scenes. But all the alpha textures and UI were wrong. Maybe the reports are wrong.

Yes this sounds a bit weird - logcat is much appreciated.

from unityandroidpermissions.

Over17 avatar Over17 commented on June 28, 2024

No updates.

from unityandroidpermissions.

fdoumhan avatar fdoumhan commented on June 28, 2024

Hi!

I think what you are observing is: https://forum.unity.com/threads/apk-with-expansion-file-obb-fails-to-load-the-second-scene-until-the-phone-has-been-restarted.465714/

The thread has quite comprehensive analysis of what's going on.

Your behavior is most likely because of the app not being able to access the OBB. The scene is becoming pink because of shaders missing; why did they end up in the OBB - that's another question - more details available here https://docs.unity3d.com/Manual/android-OBBsupport.html

The OBB is being mounted very early (before the engine is initialized), so the plugin is unable ask the user for the permission before the OBB has to be loaded.

The OBB is also mounted in onResume().

So, there's nothing with the plugin which corrupts your game. :)

Possible solutions:

  • get rid of the OBB. The most radical and the best solution. Try utilizing asset bundles instead.
  • ask for READ_EXTERNAL_STORAGE permission as soon as possible, and make Unity somehow pause and resume (show another activity? for a second) - it should make OBB loaded and fix all your issues.

Hope that helps.
Yury

I want to try the solution pause/resume unity activity.
Fo pausing, I use
activity.Call("moveTaskToBack", true);
But of course, another activity should be shown. I stuck here. How can I switch the activity for a while?
I know this is an irrelevant question with your plugin, but I searched a lot and found nothing. just need some help.

from unityandroidpermissions.

Over17 avatar Over17 commented on June 28, 2024

@fdoumhan I was thinking of the following:

  • implement an empty activity which quits in onResume() or something like that
  • in Unity activity, somewhere before the OBB is mounted, start this empty activity

from unityandroidpermissions.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.