Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Sir_Substance posted:

Well, that's frustrating. It definitely sounds like they took two separate jobs (passing data around within a single app and passing data between apps) and needlessly crushed them together.

Not at all. Intents are not for passing around data, they are for performing actions. While you typically use explicit intents within your own application, it is important to remember that their power lies with implicit intents, where you only state "I wish to view this foo" and you rely upon the most appropriate provider to do so. That provider may be in your application or in another.

If you are using intents solely to pass data around activities, rearchitect your app.

Adbot
ADBOT LOVES YOU

Sir_Substance
Dec 13, 2013
Maybe I'm missing something else obvious and simple then.

Should I be using intents to display a different activity?

Situation: I have a main menu populated with a high level overview of some information (each entry is an instance of this object). When you touch one of the entries, it should transition to a detailed view of that data.

To do this, I have made a different activity, and planned to pass the activity the object that contains the information it needs to display. To launch it I used an intent, but you cannot pass object data this way.

Basically, it's set up kinda like how you would use a modal dialog in qt/wxwidgets, except it seems android doesn't work that way.

IAmKale
Jun 7, 2007

やらないか

Fun Shoe

Sir_Substance posted:

To do this, I have made a different activity, and planned to pass the activity the object that contains the information it needs to display. To launch it I used an intent, but you cannot pass object data this way.
What about passing some kind of String or Int key in the second activity's launch intent that you then use in the second activity to requery for the detailed information? That's what I do in my dictionary app - when you find the desired entry from a list of possible matches, you tap it, a second activity opens up, and the second activity grabs all of the detailed info for that entry based on the entry's six-digit identifier.

Sir_Substance
Dec 13, 2013
That's exactly what I'm looking at doing, but I can't pretend to be impressed at a toolset that makes me do it that way, if that's really the only way :sigh:

jkyuusai
Jun 26, 2008

homegrown man milk

Karthe posted:

What about passing some kind of String or Int key in the second activity's launch intent that you then use in the second activity to requery for the detailed information? That's what I do in my dictionary app - when you find the desired entry from a list of possible matches, you tap it, a second activity opens up, and the second activity grabs all of the detailed info for that entry based on the entry's six-digit identifier.

Yeah, this is what we do basically. We store the data in a sqlite database and when transitioning from a summary to detail view, all we pass is a UUID for the thing we want to show the details of.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Sir_Substance posted:

That's exactly what I'm looking at doing, but I can't pretend to be impressed at a toolset that makes me do it that way, if that's really the only way :sigh:

The reason you need to do things this way is so that things don't break when the framework kills your app and then restarts it at some deeply-nested activity.

If you're passing around some complicated object graph, potentially with embedded references to the existing application context, it's basically going to be impossible to recreate that when relaunching your app. Forcing you to stick to communicating persistable information makes things much cleaner, unless you go out of your way to try and subvert it (in which case you kind of deserve the pain you're going to get).

speng31b
May 8, 2010

Jabor posted:

The reason you need to do things this way is so that things don't break when the framework kills your app and then restarts it at some deeply-nested activity.

If you're passing around some complicated object graph, potentially with embedded references to the existing application context, it's basically going to be impossible to recreate that when relaunching your app. Forcing you to stick to communicating persistable information makes things much cleaner, unless you go out of your way to try and subvert it (in which case you kind of deserve the pain you're going to get).

Yeah, this is right. You don't want to pass live Object references between Activities because A) it doesn't always make sense based on Activity lifecycles and the various states in which an Activity can be started and B) if you're not careful about what the Objects you want to pass reference, you could be leaking something related to dead Activities, Contexts, etc. Context leaking is bad and it's not always obvious it's happening.

Sir_Substance posted:

Maybe I'm missing something else obvious and simple then.

Should I be using intents to display a different activity?

Situation: I have a main menu populated with a high level overview of some information (each entry is an instance of this object). When you touch one of the entries, it should transition to a detailed view of that data.

To do this, I have made a different activity, and planned to pass the activity the object that contains the information it needs to display. To launch it I used an intent, but you cannot pass object data this way.

Basically, it's set up kinda like how you would use a modal dialog in qt/wxwidgets, except it seems android doesn't work that way.


I don't understand why you need to pass a live Object reference to accomplish this. It sounds like you just want a master-detail flow. You should be able to pass a serializable or parcelable Object or raw data in a bundle if it's a simple chunk of stuff to display, or a key to access the underlying data source if it's not. Why do you need to pass a live reference to the detail view Activity? Do you need it to update the state of the Object so that the calling Activity can see results of some sort? There are boilerplate ways to do that.

If you really want to have live Object references shared between Activities, you can use static memory. Of course, you'll learn a lot of painful lessons that way about why the above methods are always better if at all possible, but that's not necessarily a bad thing. Maybe you'll learn a little more about Android and won't blame the framework for trying to help you not shoot yourself in the foot.

That said, there are other ways to design your application that might allow for paradigms closer to what you're expecting. You could make a heavily Fragment-based application with a single Activity that plays host to a number of Fragments. In this scenario, you could share live Object references between Fragments by having each Fragment refer back to the host Activity and call methods on it. In each Fragment, something like:

((MainActivity) getActivity()).getSharedObject().doSomething();

This still makes a few potentially unsafe assumptions, but it's better than just clobbering anything you want to share into static memory. Either way, I would personally gravitate towards something Fragment-based instead of a screen-per-Activity approach for modern Android application design, unless you have to support back to such an old version of Android that messing with the support library Fragment stuff is just too much of a headache.

speng31b fucked around with this message at 23:28 on Oct 4, 2014

hedgecore
May 2, 2004
In the Developer Console, how often do the Play Store app statistics refresh? It says daily, but that's definitely not the case. It only reports back to a few days ago.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

It's been 3 years since I dabbled around with Android development, and I'm thinking about jumping back in to a REST CRUD app.

Any cool useful libraries I should check out for that sort of app that aren't mentioned in the OP? (or just cool libraries in general)

I see Android Studio is A Thing now. Should I just use that?

speng31b
May 8, 2010

Thermopyle posted:

It's been 3 years since I dabbled around with Android development, and I'm thinking about jumping back in to a REST CRUD app.

Any cool useful libraries I should check out for that sort of app that aren't mentioned in the OP? (or just cool libraries in general)

I see Android Studio is A Thing now. Should I just use that?

If you're starting a new project I'd definitely use Android Studio. It still has a few quirks, but they're fairly insignificant compared to Eclipse's age-old problems that will never be fixed (out of memory errors compiling, fails to regen R.java, constant restarts, etc).

The OP's still a pretty good list of libraries/creators of great libraries, but another thing I've found useful is looking through AppBrain's stats for most widely-used Android libs over here:

http://www.appbrain.com/stats/libraries/dev

P.S. - I'd use just go ahead and use OkHttp as a base for any networking you do.

speng31b fucked around with this message at 02:09 on Oct 14, 2014

kitten smoothie
Dec 29, 2001

Yeah, they're iterating like crazy on Android Studio and it's definitely perfectly fine for Doing Real Work.

You might also want to look into Retrofit for your REST stuff.

Jarl
Nov 8, 2007

So what if I'm not for the ever offended?
I'm having a problem deciding how to handle the UP button:

Activity C and D are two ways to view downloaded material.
Activity B is to select among already downloaded material.
Activity A is the starting activity, and the one where material is selected for download.

A stack could look like these:
A, B, C, D
A, B, D, C
A, B, C
A, B, D

And the stack could look the same sans b:
A, C, D
A, D, C
A, C
A, D

The parent for A is obviously B:
Parent(B) = A

The parent for C an D however is more tricky. I think a user would assume they would return to select another already downloaded material if that was what they were doing beforehand. Otherwise they would assume they would return to the start of the app:
Parent(C) = Parent(D) = "B if it exists in the stack; A otherwise"


Two problems:
1) It seems like the official Android guides on navigation only consider the possibility that an activity has one single activity as parent.

2) I have not been able to figure out an elegant way to accomplish this (which supports problem 1). However I've considered solution a and b:
a) Making every activity pop to the parent through a chain of onNewIntent until the onNewIntent of A or B stops it. Whichever comes first.
b) Having a static stack structure onto which parents are pushed and popped so that a C or D activity can go to A or B directly. Whichever is on the top of the parent stack.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

I'm looking at various option for designing the architecture for the app I just mentioned I was going to start work on.

I found this post describing a way of architecting an MVC REST app.

Any other resources like that anyone can recommend? Web or book would be great.

Jarl
Nov 8, 2007

So what if I'm not for the ever offended?
I chose a third solution:
I have an extra called parentString in C and D. A and B gives the appropriate parentString to C and D when starting them. C and D pass it along to the other. When the up button is selected in C and D parentString is used to determine what activity to pop back to.

I use the activities' class.toString as parentString.

Jarl fucked around with this message at 14:10 on Oct 15, 2014

Kenishi
Nov 18, 2010
What signature algorithm and digest alg does the Eclipse ADT plugin use to create a keystore and keys?

I've been trying to automate my build process with Maven and while I can get a debug APK to build, I've been unsuccessful in getting the maven-jarsigner-plugin to sign the APK. All I get is a fail with exit code 1. Attempting to manually sign with jarsigner using MD5withRSA & SHA1, or SHA1withRSA & SHA1 has simply resulted in an error:
code:
jarsigner error: java.security.SignatureException: private key algorithm is not compatible with signature algorithm
I built the keystore with the ADT plugin so I'm not sure if that was using a different set of algorithms or what, but I've been banging my head against the problem for nearly 2 days now. I can sign APKs with no problem in Eclipse, but gently caress if I can do it via maven or CLI jarsigner.

Sereri
Sep 30, 2008

awwwrigami

Has anyone material design-ified their apps yet? Any tips?


Also whats is up with Android Studios updater? Half the time it updates itself, the other half it sends me to a download site.

CheddarGoblin
Jan 12, 2005
oh
I'm looking for the absolute easiest way to make a small app/widget/SOMETHING to make a simple ajax call on android. I'm not even sure if that's the right terminology, I'm not a developer at all just a sysadmin/IT goon. All I need is a button to make the call, and possibly read the result and tell me "ok" or "poo poo hosed up" but that's not a show stopper if it complicates things.

My problem is this: I have a webserver running on a raspberry pi at home with some custom php/python code for the purposes of opening and closing my drive gate (the gate opener is wired up the pi's GPIO). I use it all the time for when I need to open the gate but don't have the bigass opener on me, like when I'm on my scooter or motorcycle.

The way I do it now is I have the pi serve up a simple web page with a single button. I hit the button, it makes an ajax call to a php script on the pi which activates the gate.

This works, but it's annoying on android. It takes a long time to load the page sometimes because the pi makes a poo poo webserver. The page is small obviously, but with jquery it still approaches 100k. Sometimes it loads zoomed in all weird, sometimes it's normal, sometimes it opens a new tab, sometimes it uses the existing one (this is when launching from a bookmark widget on the home screen). I don't want to get into all the details but suffice to say that it's clunky through chrome on android.

I tried using tasker to make a little webview app but it was janky as hell too. I tried copying the main page and jquery to the phone and loading it up locally, which works, but what sucks is that I have to open up chrome first, and then load the bookmark for it. Android won't open local html files in chrome through the launcher, even when I use chrome's bookmark widget. It says "App isn't installed" when I click the shortcut.

There's got to be an easier way. If it were a linux workstation I'd just make a curl script and be done with it.

IAmKale
Jun 7, 2007

やらないか

Fun Shoe
I don't have any direct experience with this but you could probably recreate the button's GET/POST request using the Apache HTTP client that's built into Android: http://stackoverflow.com/questions/3505930/make-an-http-request-with-android

Push a Button, launch an AsyncTask and then update the app to show whatever the script returns so you know it fired properly. If you wanted to simplify things even further you could include a small, super-basic widget that you could stick on the homescreen. Widgets are limited in the ways you can interact with them but tap-to-launch-event are definitely within that list of possibilities.

mod sassinator
Dec 13, 2006
I came here to Kick Ass and Chew Bubblegum,
and I'm All out of Ass

the nicker posted:

I'm looking for the absolute easiest way to make a small app/widget/SOMETHING to make a simple ajax call on android. I'm not even sure if that's the right terminology, I'm not a developer at all just a sysadmin/IT goon. All I need is a button to make the call, and possibly read the result and tell me "ok" or "poo poo hosed up" but that's not a show stopper if it complicates things.

My problem is this: I have a webserver running on a raspberry pi at home with some custom php/python code for the purposes of opening and closing my drive gate (the gate opener is wired up the pi's GPIO). I use it all the time for when I need to open the gate but don't have the bigass opener on me, like when I'm on my scooter or motorcycle.

The way I do it now is I have the pi serve up a simple web page with a single button. I hit the button, it makes an ajax call to a php script on the pi which activates the gate.

This works, but it's annoying on android. It takes a long time to load the page sometimes because the pi makes a poo poo webserver. The page is small obviously, but with jquery it still approaches 100k. Sometimes it loads zoomed in all weird, sometimes it's normal, sometimes it opens a new tab, sometimes it uses the existing one (this is when launching from a bookmark widget on the home screen). I don't want to get into all the details but suffice to say that it's clunky through chrome on android.

I tried using tasker to make a little webview app but it was janky as hell too. I tried copying the main page and jquery to the phone and loading it up locally, which works, but what sucks is that I have to open up chrome first, and then load the bookmark for it. Android won't open local html files in chrome through the launcher, even when I use chrome's bookmark widget. It says "App isn't installed" when I click the shortcut.

There's got to be an easier way. If it were a linux workstation I'd just make a curl script and be done with it.

I would check out some of the app development frameworks like AppInventor http://appinventor.mit.edu/explore/ or Apache Cordova http://cordova.apache.org/ I'd be really surprised if they couldn't help you make something to call a web URL without too much pain.

CheddarGoblin
Jan 12, 2005
oh
Got a working app in 10 minutes with app inventor :aaa:

Jarl
Nov 8, 2007

So what if I'm not for the ever offended?
Having added a runnable to the ui-main-thread using Activity.runOnUiThread(Runnable), View.post(Runnable) or View.postDelayed(Runnable, long) is it then omitted when it's about to be run if the activity has been destroyed?

I assuming not, but I've been unable to get any confirmation. If so I'm considering checking with isFinishing() inside the runnable's run() method.

Jarl fucked around with this message at 17:01 on Nov 6, 2014

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

Anyone have any experience working with GLSurfaceViews, especially as a wallpaper? Or some debugging skills that could point me in the right direction? I'm having this weird issue where there's severe lag when you scroll the launcher's screens, or hit the app tray button. It seems completely variable, but we can be talking between half a second scroll lag to a couple of seconds waiting for the app tray animation to kick in (both in Nova and the stock launcher).

I've done a few method profiling traces in DDMS, and I get this kind of thing (this is a fast swipe, so the actual motion from touch to release was really a fraction of a second):



As far as I'm aware, I'm doing nothing on the UI thread - the GLSurfaceView spins off its own thread for the rendering, which is where the work is going on. Not that that seems to matter, because the other weird thing is that I have different scenes I can render on the surfaceview, and one in particular is completely responsive - snappy and immediately reacts.

It's more complex than some other scenes that lag, both in terms of drawing and preprocessing. I can crank the complexity so with the debugger running it's about 2fps, with sensor polling on the UI thread, and the launcher performs perfectly, smooth and snappy while the wallpaper is chugging away under it.

The underlying engine is the same for all the scenes, so I can't really spot any common factor that would hurt some but not another. And my understanding is that the launcher shouldn't care (like with the snappy scene) and any poor performance should be restricted to the wallpaper itself. The launcher/app tray lag seems like it's getting blocked somehow.


Anyway tldr, does anyone have any advice where to go from here in tracking this down? All I can see in traceview is that nebulous MessageQueue.nativePollOnce call with all its time taken up by context switching, which corresponds to the launcher lag. Is there any more detective work I can do here?

baka kaba fucked around with this message at 02:55 on Nov 7, 2014

Safe and Secure!
Jun 14, 2008

OFFICIAL SA THREAD RUINER
SPRING 2013
So what's the state of android development tools? Is everything still the biggest pain in the rear end possible? I want to play around with android but I dread spending a day to get a hello world app running on my phone because I have to download a special version of eclipse and then make sure I've got a billion different plugins installed and configured properly.

Doctor w-rw-rw-
Jun 24, 2008

Safe and Secure! posted:

So what's the state of android development tools? Is everything still the biggest pain in the rear end possible? I want to play around with android but I dread spending a day to get a hello world app running on my phone because I have to download a special version of eclipse and then make sure I've got a billion different plugins installed and configured properly.

I say this despite liking and preferring Eclipse over IntelliJ - just use Android Studio.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Safe and Secure! posted:

So what's the state of android development tools? Is everything still the biggest pain in the rear end possible? I want to play around with android but I dread spending a day to get a hello world app running on my phone because I have to download a special version of eclipse and then make sure I've got a billion different plugins installed and configured properly.

Pick up Android Studio(beta), which is basically IntelliJ with the Android plugin built in. The build system is built atop gradle now and everything is very sensible. Things have improved over the last several years, I'm not sure what version of Eclipse you tried with last.

Jarl posted:

Having added a runnable to the ui-main-thread using Activity.runOnUiThread(Runnable), View.post(Runnable) or View.postDelayed(Runnable, long) is it then omitted when it's about to be run if the activity has been destroyed?

I assuming not, but I've been unable to get any confirmation. If so I'm considering checking with isFinishing() inside the runnable's run() method.

For Activity.runOnUiThread, it will definitely be pushed to the UI Looper's queue. For View.post(delayed), this appears to happen as well but I can't guarantee that (it should be easy to check though!)

Jarl
Nov 8, 2007

So what if I'm not for the ever offended?

Volmarias posted:

For Activity.runOnUiThread, it will definitely be pushed to the UI Looper's queue. For View.post(delayed), this appears to happen as well but I can't guarantee that (it should be easy to check though!)

It is, and since there is no information given with the static method about what activity the runnable is relevant to, I have to check that it hasn't been destroyed in the meantime.

Tunga
May 7, 2004

Grimey Drawer
ListViews seem to be unnecessarily complicated. Anyone have a good article explaining the best way to get a bunch of structured data (in my case some JSON) into a ListView with multiple text/image items on each line? I'm guessing I need a custom View which inherits from whatever a ListView displays?

Tunga fucked around with this message at 13:00 on Nov 7, 2014

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Tunga posted:

ListViews seem to be unnecessarily complicated. Anyone have a good article explaining the best way to get a bunch of structured data (in my case some JSON) into a ListView with multiple text/image items on each line? I'm guessing I need a custom View which inherits from whatever a ListView displays?

Extend a new BaseAdapter and use a custom view as you suggested. It's pretty straightforward. Just make sure you recycle your views (read the article!)

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Tunga posted:

ListViews seem to be unnecessarily complicated. Anyone have a good article explaining the best way to get a bunch of structured data (in my case some JSON) into a ListView with multiple text/image items on each line? I'm guessing I need a custom View which inherits from whatever a ListView displays?

The easy way to get data into a ListView:

- Create a custom subclass of BaseAdapter.
- Implement getCount() to return the total number of items in your data set.
- Implement getView(int position, View convertView, ViewGroup parent) to inflate a new view from whatever layout you want to use, populate it with the data from the appropriate position in your data set, and return it.
- Give the ListView your adapter.

Once you've got that working, there are some other steps that you'll want to do:

- call notifyDataSetChanged() when the underlying data changes so that the ListView knows to refresh itself.
- Re-use the convertView that gets passed into your getView() method (if possible) to avoid re-inflating views all the time.

There are other classes like ArrayAdapter and CursorAdapter and SimpleCursorAdapter and stuff - you can just ignore them for now. Subclassing BaseAdapter is both easy, and gives you the best understanding of how the framework actually works. After you've figured everything out, then you can take a look at the other options and see if one of them fits your use case better.

Sereri
Sep 30, 2008

awwwrigami

Tunga posted:

ListViews seem to be unnecessarily complicated. Anyone have a good article explaining the best way to get a bunch of structured data (in my case some JSON) into a ListView with multiple text/image items on each line? I'm guessing I need a custom View which inherits from whatever a ListView displays?

Basically yes. You need a ListView, an adapter and a view that the adapter inflates, stuff your data into and puts into the ListView.


Actually well explained by ^^^

Sereri fucked around with this message at 13:26 on Nov 7, 2014

Tunga
May 7, 2004

Grimey Drawer

Jabor posted:

- Create a custom subclass of BaseAdapter.
- Implement getCount() to return the total number of items in your data set.
- Implement getView(int position, View convertView, ViewGroup parent) to inflate a new view from whatever layout you want to use, populate it with the data from the appropriate position in your data set, and return it.
- Give the ListView your adapter.
Thanks, this was wonderfully succinct and a lot easier to comprehend that a lot of the giant articles I found which started going into a ton of details before explaining the basics.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Tunga posted:

Thanks, this was wonderfully succinct and a lot easier to comprehend that a lot of the giant articles I found which started going into a ton of details before explaining the basics.

No problem! I honestly did consider just linking to the documentation, but then I decided to read it from the perspective of someone who doesn't already know how this stuff works and ... it is not particularly helpful. Either there's a hidden section I haven't been able to find, or they just left out the basics and jumped straight into the "so now that you know how adapters and such work, here's some convenience implementations that could save you some time" part. So I figured I'd better write something about the correct way to get started.

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

Tunga posted:

Thanks, this was wonderfully succinct and a lot easier to comprehend that a lot of the giant articles I found which started going into a ton of details before explaining the basics.

This might be worth a read once you've got the idea down too (especially if you're getting lint complaints)

http://lucasr.org/2012/04/05/performance-tips-for-androids-listview/

kitten smoothie
Dec 29, 2001

Is the RecyclerView the new blessed replacement for ListView going forward? If nothing else it's nice that you finally can use it for horizontal scrolling lists.

Sereri
Sep 30, 2008

awwwrigami

I wanted to use AppCompats Light theme but it turns everything on the actionbar toolbar black except for the drawer arrow.

I tried a couple of things but I can't figure out how to turn everything white.

The weirdest thing is that the drawable looks white in AS but it's black in the app.

Tunga
May 7, 2004

Grimey Drawer

Sereri posted:

I wanted to use AppCompats Light theme but it turns everything on the actionbar toolbar black except for the drawer arrow.

I tried a couple of things but I can't figure out how to turn everything white.

The weirdest thing is that the drawable looks white in AS but it's black in the app.
I made a post about something very similar ages ago where I wanted to use a coloured action bar with dark icons on an otherwise dark theme. The only solution I found was to add my own assets and override the default ones.

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

It says drawable tinting only works on 5.0, if that's what you're doing?

https://developer.android.com/training/material/compatibility.html#CheckVersion

Sereri
Sep 30, 2008

awwwrigami

It was occurring on all versions.

I just managed to solve it by applying app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" on the toolbar.
Since I want white icons whether it's my normal or light theme, this seems to work.

genki
Nov 12, 2003

Jarl posted:

Having added a runnable to the ui-main-thread using Activity.runOnUiThread(Runnable), View.post(Runnable) or View.postDelayed(Runnable, long) is it then omitted when it's about to be run if the activity has been destroyed?

I assuming not, but I've been unable to get any confirmation. If so I'm considering checking with isFinishing() inside the runnable's run() method.
I think this blog post directly addresses your question:
http://corner.squareup.com/2013/12/android-main-thread-2.html

baka kaba posted:

Anyone have any experience working with GLSurfaceViews, especially as a wallpaper? Or some debugging skills that could point me in the right direction? I'm having this weird issue where there's severe lag when you scroll the launcher's screens, or hit the app tray button. It seems completely variable, but we can be talking between half a second scroll lag to a couple of seconds waiting for the app tray animation to kick in (both in Nova and the stock launcher).

I've done a few method profiling traces in DDMS, and I get this kind of thing (this is a fast swipe, so the actual motion from touch to release was really a fraction of a second):



As far as I'm aware, I'm doing nothing on the UI thread - the GLSurfaceView spins off its own thread for the rendering, which is where the work is going on. Not that that seems to matter, because the other weird thing is that I have different scenes I can render on the surfaceview, and one in particular is completely responsive - snappy and immediately reacts.

It's more complex than some other scenes that lag, both in terms of drawing and preprocessing. I can crank the complexity so with the debugger running it's about 2fps, with sensor polling on the UI thread, and the launcher performs perfectly, smooth and snappy while the wallpaper is chugging away under it.

The underlying engine is the same for all the scenes, so I can't really spot any common factor that would hurt some but not another. And my understanding is that the launcher shouldn't care (like with the snappy scene) and any poor performance should be restricted to the wallpaper itself. The launcher/app tray lag seems like it's getting blocked somehow.


Anyway tldr, does anyone have any advice where to go from here in tracking this down? All I can see in traceview is that nebulous MessageQueue.nativePollOnce call with all its time taken up by context switching, which corresponds to the launcher lag. Is there any more detective work I can do here?
I think you already answered your own question, which is to say that some scenes don't lag and some scenes do. Without actually knowing what the GL side is doing, it's tough to tell what the issue could be, but most likely I'd guess that somehow certain scenes have some sort of dependency on the UI thread which are blocking UI operations while the scene is running. That's the only explanation I think would make sense, assuming certain scenes always work correctly and certain scenes always cause the lag issues.

Adbot
ADBOT LOVES YOU

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

genki posted:

I think this blog post directly addresses your question:
http://corner.squareup.com/2013/12/android-main-thread-2.html

I think you already answered your own question, which is to say that some scenes don't lag and some scenes do. Without actually knowing what the GL side is doing, it's tough to tell what the issue could be, but most likely I'd guess that somehow certain scenes have some sort of dependency on the UI thread which are blocking UI operations while the scene is running. That's the only explanation I think would make sense, assuming certain scenes always work correctly and certain scenes always cause the lag issues.

I dug around more and here's the weird thing - the problem happens on every scene, and it's worse the better the renderer is running! That one I cranked up with extra duplicate objects and it was super smooth, if I turn it down to a minimal number of objects it runs faster but then the launcher performs worse. It's not entirely down to that, I think fill rate is having an effect (scenes with a lot of full-screen overdraw lag more at the same fps) but it's hard to know for sure.

There's nothing blocking the UI thread from what I can see, I turned off the only thing doing any event handling to check and nope, no difference. I have a trace where the main thread seems to be doing nothing (it's in MessageQueue.nativePollOnce() which the UI thread idles in, waiting for messages), and after a few seconds it ends up calling MessageQueue.next() and the GL thread gets its cleanup calls pretty soon after.

So really it's that initial delay, in the message queue from what I can tell, but the whole thing's pretty opaque and I'm having to trawl through a ton of framework source code to try and work out what might be happening in there. I've had some logcat from InputReceiver reports of the launcher taking X seconds to handle a MotionEvent

If it was just fighting with the system drawing system for time on the GPU I'd understand that, it would make sense and it would look juddery and rough but this is a delay of hundreds of frames with no visible reaction, like the launcher itself is blocking in response the touch events. It's obviously fine in some situations (like very low framerates on the GL thread) and with other wallpapers, so there's some weird interaction that seems like it's related to Message handling, but I'm still digging

If anyone has any insights about cross-app/service communication with the message queue and if there's anything that might block (especially relating to that big context switch, what's actually happening in there?), that would be real appreciated!

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply