[Fixed] Not found image crashes Android client

Discussion in 'Solved Bugs' started by Camilo, Nov 30, 2015.

  1. Camilo

    Camilo Member

    Joined:
    Apr 10, 2014
    Messages:
    53
    Likes Received:
    2
    When a Android device receives a <img src=icon:undefined> it crashes, so, it's a minor bug, but try to fix it :)
     
    Last edited: Dec 1, 2015
  2. MidwayMarshall

    MidwayMarshall woof Forum Moderator Developer Forum Moderator Developer

    Joined:
    Jun 13, 2014
    Messages:
    303
    Likes Received:
    170
    Why would a server send that
     
  3. Nightfall Alicorn

    Nightfall Alicorn Left Pokémon Online, most likely not coming back.

    Joined:
    Oct 15, 2013
    Messages:
    491
    Likes Received:
    171
    PO Trainer Name:
    Nightmare Moon
    Coding error I guess? '-' There should be no reason why the main server would return that though.
     
  4. Camilo

    Camilo Member

    Joined:
    Apr 10, 2014
    Messages:
    53
    Likes Received:
    2
    For example, i have a new Mega Evolution like "Mega Ho-Oh" in my server, (i actually have it) a android player can't battle with it because it does get bugged.
     
  5. Nightfall Alicorn

    Nightfall Alicorn Left Pokémon Online, most likely not coming back.

    Joined:
    Oct 15, 2013
    Messages:
    491
    Likes Received:
    171
    PO Trainer Name:
    Nightmare Moon
    Sounds like you would need to modify an android app and apply the image so they can use it. Or maybe, better option, add a condition if the user is using android on server script, make it show default Ho-oh or use outside link to a domain hosting if it supports it.
     
  6. Camilo

    Camilo Member

    Joined:
    Apr 10, 2014
    Messages:
    53
    Likes Received:
    2
    So, exactly, but instead of avoid the fix, you should do something, in PC the new Megas are just not shown but in Android it makes it crash, and you can distribute the new Version with the corresponding fix, but if i do that not everyone will have acces to the version... so, try to fix it it should be an Infinite loop, and the fix will help all Android people to use and Watch battles without crash
     
  7. MidwayMarshall

    MidwayMarshall woof Forum Moderator Developer Forum Moderator Developer

    Joined:
    Jun 13, 2014
    Messages:
    303
    Likes Received:
    170
    This isn't how the images are displayed in battle for any client.

    There is code from 2013 to handle missing resources for a pokemon number. It probably crashes due to missing the pokemon in the info files, but I would need to go on the server and crash to find out.
     
  8. Camilo

    Camilo Member

    Joined:
    Apr 10, 2014
    Messages:
    53
    Likes Received:
    2
    Really sorry, pokemon:undefined does not bug, is icon:undefined
     
  9. MidwayMarshall

    MidwayMarshall woof Forum Moderator Developer Forum Moderator Developer

    Joined:
    Jun 13, 2014
    Messages:
    303
    Likes Received:
    170
    To be clear. Are you reporting a crash from battling or a crash from chat?
     
  10. Camilo

    Camilo Member

    Joined:
    Apr 10, 2014
    Messages:
    53
    Likes Received:
    2
    Both, anywhere you get an undefined icon you will be crashed, in battles the Android Client i think, you get the poke, and cause it does not exist in the db, it will be searching forever. In PC it does not happen
     
  11. MidwayMarshall

    MidwayMarshall woof Forum Moderator Developer Forum Moderator Developer

    Joined:
    Jun 13, 2014
    Messages:
    303
    Likes Received:
    170
    are you literally sending <img src=icon:undefined> or are you sending <img src=icon:65786> which is mega ho-oh?
     
  12. Camilo

    Camilo Member

    Joined:
    Apr 10, 2014
    Messages:
    53
    Likes Received:
    2
    I am not sendin anything, so, i'll take a while to explain my point:

    1) Let's start by the point: "<img src=icon:undefined>" crashes Android.
    2) In any scenario, battles or chat if an Android receives "<img src=icon:undefined>" it will crash
    3) Normally in chat, exceptuating for a mal-programmed script functionality, "<img src=icon:undefined>" should not be sent
    4) When a Android receives in battle a pokemon, it does load the icon, but if the icon is undefined, it will loop forever, and the Android will Crash, please fix it qwq i really want to play Mega Mastery and other fun tiers with Android people
     

    Attached Files:

  13. Fuzzysqurl

    Fuzzysqurl baa baa mareep I do what I want Server Owner Developer I do what I want Server Owner Developer

    Joined:
    Sep 12, 2012
    Messages:
    2,096
    Likes Received:
    967
    Midwaymarshall was asking, are you sending <img src=icon:undefined> or <img src=icon:65786>. It's literally looking for a number. You could put in any number from 0 to infinity and it would work. Granted, only a very small amount of numbers will work (as in, valid dex numbers) otherwise it defaults to the missingno icon. When it receives text, as in "undefined" it doesn't know what to do and crashes.

    This could mean the data for the new mega pokemon was not set up completely and is missing a value somewhere along the lines.
     
  14. Camilo

    Camilo Member

    Joined:
    Apr 10, 2014
    Messages:
    53
    Likes Received:
    2
    So, try to fix the algorithm :) Make it more robust
     
  15. Fuzzysqurl

    Fuzzysqurl baa baa mareep I do what I want Server Owner Developer I do what I want Server Owner Developer

    Joined:
    Sep 12, 2012
    Messages:
    2,096
    Likes Received:
    967
    You've got something else broken in the content delivery chain that should be fixed too.
     
    Last edited: Dec 5, 2015
  16. MidwayMarshall

    MidwayMarshall woof Forum Moderator Developer Forum Moderator Developer

    Joined:
    Jun 13, 2014
    Messages:
    303
    Likes Received:
    170
    Again html is not used in battles to display images camilo. But if you are so fixated on the algorithm for html parsing here it is.

    Two things break getLocalName for icons: a string or a number that is larger than 0x7FFFFFFF or lower than 0x80000000. But getLocalName is wrapped in a try block catching NumberFormatExceptions and StringIndexOutOfBoundsExceptions so it would not cause a crash.

    Code (java):
    1. String source = getLocalName(src);
    2. ...
    3. int Identifier = resources.getIdentifier(source, "drawable", pkgName);
    4. if (Identifier == 0) { // If it's 0 it means it could not locate the resource
    5.   return getResource("pi_0"); // And defaults to missingo's icon
    6. }
    7. else { // Otherwise retrieve image from resources
    8.   Drawable drawable = resources.getDrawable(Identifier);
    9.   drawable.setBounds(0,0,drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    10.   return drawable;
    11. }
    12.  
    13. private String getLocalName(String src) {
    14. ...
    15.   if (src.indexOf("icon:") == 0) {
    16.     int i = Integer.parseInt(src.replace("icon:", ""));
    17.     int j = i >> 16;
    18.     i = i - (j << 16);
    19.     return "pi_" + i + (j == 0 ? "" : "_" + j);
    20.   }
    21. ...
    22. }
    I tried to find a battle with mega mastery for awhile on Pokemon Espanol but didn't.
     
  17. MidwayMarshall

    MidwayMarshall woof Forum Moderator Developer Forum Moderator Developer

    Joined:
    Jun 13, 2014
    Messages:
    303
    Likes Received:
    170
    Okay how about this @Camilo
    You start a mega mastery battle on Pokemon Espanol with mega arbok or w/e out and don't make any moves while I debug my android phone so I can fix this problem.
     
  18. MidwayMarshall

    MidwayMarshall woof Forum Moderator Developer Forum Moderator Developer

    Joined:
    Jun 13, 2014
    Messages:
    303
    Likes Received:
    170
    I watched an entire mega mastery battle without crashing. It did go a little crazy at points as well as not giving any custom pokemon names

    [​IMG]
     
  19. Camilo

    Camilo Member

    Joined:
    Apr 10, 2014
    Messages:
    53
    Likes Received:
    2
    That's very weard, every people i know get crashed by new Megas
     
  20. MidwayMarshall

    MidwayMarshall woof Forum Moderator Developer Forum Moderator Developer

    Joined:
    Jun 13, 2014
    Messages:
    303
    Likes Received:
    170
    Can you send me a link to the mod? I think the error is with instantiating the shallowbattlepoke class, which would explain why the level shows 0 (because thats the default value without constructors)

    Also I'm playing android 2.6.1, that would be why I'm not crashing
     
  21. turbedi

    turbedi Professional circle clicker ~~~ Forum Moderator Developer Forum Moderator Developer

    Joined:
    Jul 18, 2013
    Messages:
    385
    Likes Received:
    155
    PO Trainer Name:
    turbedi
    Is this still an issue?
     
  22. MidwayMarshall

    MidwayMarshall woof Forum Moderator Developer Forum Moderator Developer

    Joined:
    Jun 13, 2014
    Messages:
    303
    Likes Received:
    170
    On the latest version it handled the errors without crashing. I got tired of trying to find players to help me debug the issue and no one seemed to know where the download to the mod was so I could test it myself by desktop.

    It could be throwing an error from ShallowBattlePoke::39 and may be amended by changing PokemonInfo::101 to return pokeNames.get(num, "Default Value");
    ShallowBattlePoke::50&51 also make database calls but they seem to be better guarded against null entries

    But it was a generally unhelpful situation for me to resolve.
     
    Fuzzysqurl likes this.
  23. Camilo

    Camilo Member

    Joined:
    Apr 10, 2014
    Messages:
    53
    Likes Received:
    2
    Enter Pokemon Español and ask for "Camilo", so we can solve de issue :)