aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/ok.cpp
Commit message (Collapse)AuthorAge
* use fcntl() to lock/unlock fdsGravatar Mike Klein2017-08-30
| | | | | | | | | | This is portable back to older Android NDK APIs. Seems to work fine. Change-Id: I1f121f372d376909011ffd7063b73cbe50402a5f Reviewed-on: https://skia-review.googlesource.com/40688 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* ok, backtrace support on AndroidGravatar Mike Klein2017-08-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a fallback backtracer for use on Android where <execinfo.h> ins't present, instead using <unwind.h> to unwind and <dlfcn.h> to lookup function names and addresses. lockf() wasn't available until NDK API 24, so I've just no-op'd file locking on older targets. I tried switching from lockf() to flock(), but flock() didn't see to _do_ anything, neither on Android nor on my Mac laptop. I think I should be able to use the lower-level fcntl() APIs to restore file locking uniformly in a follow-up. The upshot is until then, we'll have interlaced logs and stack traces on Android devices unless you set ndk_api=24 in GN. We need to add a couple build flags to make backtraces useful: * -funwind-tables makes the call to _Unwind_Backtrace() actually traverse the call stack. This is a small extra binary size cost. * -rdynamic makes symbols linked into the main executable visible to dladdr(). We do this on Linux already for the same reason. Here's an example where I made aaxfermodes call SK_ABORT(): 650 ok, 1 crashed caught signal SIGABRT while running 'aaxfermodes' 0x76ed936288 [unknown]+308 0x76eec014e0 [unknown]+510811706592 0x76ed367b2c tgkill+8 0x76ed364f50 pthread_kill+68 0x76ed31ff5c raise+28 0x76ed318814 abort+56 0x76edebd070 sk_out_of_memory()+12 0x76ed99f664 AAXfermodesGM::draw_pass(SkCanvas*, AAXfermodesGM::DrawingPass)+96 0x76ed99f4e4 AAXfermodesGM::onDraw(SkCanvas*)+36 0x76ed9e8550 skiagm::GM::drawContent(SkCanvas*)+224 0x76ed9e82ac skiagm::GM::draw(SkCanvas*)+288 0x76ed93b10c GMStream::GMSrc::draw(SkCanvas*)+96 0x76ed937b08 SWDst::draw(Src*)+284 0x76ed936ca0 [unknown]+112 0x76ed939b4c ForkEngine::spawn(std::function<Status ()>)+88 0x76ed934d00 main+2200 0x76ed316598 __libc_init+92 0x76ed93434c [unknown]+510791992140 Change-Id: Ica4849d99a3b97f48d778f4c15a7fa36275b8133 Reviewed-on: https://skia-review.googlesource.com/40802 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* print running task in both ok_log()Gravatar Mike Klein2017-08-30
| | | | | | | Change-Id: Ie69421ed36d596cb8c40f9858fac370ceba18c87 Reviewed-on: https://skia-review.googlesource.com/40022 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
* factor Engine out of ok coreGravatar Mike Klein2017-07-26
| | | | | | | | | | | | | | This makes Engines (task execution strategies: serial, thread, fork) pluggable just like most of the rest of ok. It removes the thread and process limits, as I find myself rarely caring about what they are exactly. Instead of limiting to num-cores, we just allow any number of concurrent threads, and any number of concurrent child processes subject to OS limitations. Change-Id: Icef49d86818fe9a4b7380efb60e73e40bc2e6b73 Reviewed-on: https://skia-review.googlesource.com/27140 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
* Revert "ok, exit() child processes instead of _exit()"Gravatar Mike Klein2017-07-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 9ac801c12c48b67b48e5a8ef2876a093b7de73fc. Reason for revert: breaks threaded mode. Original change's description: > ok, exit() child processes instead of _exit() > > We want the atexit() hook to print deferred logs (crash dumps, etc.) only when the main, parent process exits. Ending the child processes with _exit() instead of exit() avoids calling atexit() hooks, but also global destructors. This is more complex than we need: we can just print before main() exits. Only the main, parent process gets there. > > This now runs each child process' global destructors, which makes trace.json "work": we get a trace of whichever child process finishes last. It's a start. > > Change-Id: I0cc2b12592f0f79e73a43a160b9fd06dba1fee25 > Reviewed-on: https://skia-review.googlesource.com/26800 > Commit-Queue: Mike Klein <mtklein@chromium.org> > Reviewed-by: Brian Osman <brianosman@google.com> TBR=mtklein@chromium.org,brianosman@google.com Change-Id: I695dddaab3b5a51e4698bb7222fc723b544a1d64 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/26943 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Mike Klein <mtklein@google.com>
* ok, exit() child processes instead of _exit()Gravatar Mike Klein2017-07-26
| | | | | | | | | | | We want the atexit() hook to print deferred logs (crash dumps, etc.) only when the main, parent process exits. Ending the child processes with _exit() instead of exit() avoids calling atexit() hooks, but also global destructors. This is more complex than we need: we can just print before main() exits. Only the main, parent process gets there. This now runs each child process' global destructors, which makes trace.json "work": we get a trace of whichever child process finishes last. It's a start. Change-Id: I0cc2b12592f0f79e73a43a160b9fd06dba1fee25 Reviewed-on: https://skia-review.googlesource.com/26800 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Brian Osman <brianosman@google.com>
* Revert "Revert "Reland: Remove SkLights include from SkCanvas.h""Gravatar Florin Malita2017-05-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 9d5f66d9c21eda7d3e2ed47654180c0c4b6e38b1. Reason for revert: Leon landed Android fixes. Original change's description: > Revert "Reland: Remove SkLights include from SkCanvas.h" > > This reverts commit fed00319c9bafa41c8df658708030c072b301a41. > > Reason for revert: breaking the Android roll. > > Original change's description: > > Reland: Remove SkLights include from SkCanvas.h > > > > SkLights.h pulls in a bunch of other headers and is not needed (fwdecl > > works fine). > > > > Change-Id: I3ed97cd7861e51dcb7cfa7950a97b420dbc6fbfb > > TBR=reed@google.com > > Reviewed-on: https://skia-review.googlesource.com/15143 > > Commit-Queue: Florin Malita <fmalita@chromium.org> > > Reviewed-by: Florin Malita <fmalita@chromium.org> > > > > TBR=fmalita@chromium.org,reed@google.com > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > > Change-Id: I3b0e69f1d04d160f16a5567b09982d35cc9ca84e > Reviewed-on: https://skia-review.googlesource.com/15195 > Reviewed-by: Florin Malita <fmalita@chromium.org> > Commit-Queue: Florin Malita <fmalita@chromium.org> > TBR=msarett@google.com,reviews@skia.org,fmalita@chromium.org,reed@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I0a1c2f9df61f16987ab72dfb4f3a205fbcc37667 Reviewed-on: https://skia-review.googlesource.com/15229 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Revert "Reland: Remove SkLights include from SkCanvas.h"Gravatar Florin Malita2017-05-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit fed00319c9bafa41c8df658708030c072b301a41. Reason for revert: breaking the Android roll. Original change's description: > Reland: Remove SkLights include from SkCanvas.h > > SkLights.h pulls in a bunch of other headers and is not needed (fwdecl > works fine). > > Change-Id: I3ed97cd7861e51dcb7cfa7950a97b420dbc6fbfb > TBR=reed@google.com > Reviewed-on: https://skia-review.googlesource.com/15143 > Commit-Queue: Florin Malita <fmalita@chromium.org> > Reviewed-by: Florin Malita <fmalita@chromium.org> > TBR=fmalita@chromium.org,reed@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I3b0e69f1d04d160f16a5567b09982d35cc9ca84e Reviewed-on: https://skia-review.googlesource.com/15195 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Reland: Remove SkLights include from SkCanvas.hGravatar Florin Malita2017-05-03
| | | | | | | | | | | SkLights.h pulls in a bunch of other headers and is not needed (fwdecl works fine). Change-Id: I3ed97cd7861e51dcb7cfa7950a97b420dbc6fbfb TBR=reed@google.com Reviewed-on: https://skia-review.googlesource.com/15143 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Florin Malita <fmalita@chromium.org>
* Revert "Remove SkLights include from SkCanvas.h"Gravatar Florin Malita2017-05-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 9ff301bf918cd85d9f67047f10631b7a74345a90. Reason for revert: need to update G3, Flutter. Original change's description: > Remove SkLights include from SkCanvas.h > > SkLights.h pulls in a bunch of other headers and is not needed (fwdecl > works fine). > > Change-Id: Id2d7176eb3bf4609f72f46d513eebf59318f542f > Reviewed-on: https://skia-review.googlesource.com/14904 > Reviewed-by: Mike Reed <reed@google.com> > Commit-Queue: Florin Malita <fmalita@chromium.org> > TBR=mtklein@google.com,fmalita@chromium.org,reed@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I4799ad5b31aaeaf529c8b912bbe09aa8869a5e6c Reviewed-on: https://skia-review.googlesource.com/15107 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Remove SkLights include from SkCanvas.hGravatar Florin Malita2017-05-02
| | | | | | | | | | SkLights.h pulls in a bunch of other headers and is not needed (fwdecl works fine). Change-Id: Id2d7176eb3bf4609f72f46d513eebf59318f542f Reviewed-on: https://skia-review.googlesource.com/14904 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
* In ok thread mode, use wait_util instead of wait_for.Gravatar Mike Klein2017-04-27
| | | | | | | | | | | | | | | | wait_for(delta) is wait_until(steady_clock::now() + delta) under the hood, so using wait_for() like this implies an extra call to now() that we can avoid by using wait_until(). We can hoist that call out and just do it once... the past stays the past. This is not super important. Just noticed while profiling. It's nice to keep the overhead of the ok tool down so the real work can show. :) Change-Id: I89d25a800b63ebcfc229b5b3aa3f2dd621f4e7b4 Reviewed-on: https://skia-review.googlesource.com/14480 Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Herb Derby <herb@google.com>
* tidy up ok helpGravatar Mike Klein2017-04-12
| | | | | | | | | | | | -m, -s, and -w are now vias. No real need to advertise -h given that if you just run ok with no arguments it prints the help, but to be friendly accept -h and --help. Change-Id: Id23936106cfea7d670cf0eb9773a5851055576f1 Reviewed-on: https://skia-review.googlesource.com/13254 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
* ok, most features can be viasGravatar Mike Klein2017-03-31
| | | | | | | | | | | | | This refactors most features out of ok's core into vias: -w --> a .png dumping via, "png", opening the door to other types -m/-s --> a filtering via "filter" Everything now can print a brief help message too. Change-Id: I9e653aab98fd57182a6d458c7a80052130980284 Reviewed-on: https://skia-review.googlesource.com/10509 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
* ok, unify failure and crash loggingGravatar Mike Klein2017-03-28
| | | | | | | | | | Just as deferred and locked crash logging makes crashes easier to read, so does deferred and locked failure logging make failures easier to read. Change-Id: I71578d61b0056f8d7e692149762def1f155c0387 Reviewed-on: https://skia-review.googlesource.com/10280 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* ok: add basic unit test supportGravatar Mike Klein2017-03-27
| | | | | | | | | | | | | | | Plenty TODO remaining. This can actually kind of run without a test reporter or GrContext: $ out/ok test 784 ok, 56 crashed ... lots of stack traces ... Most tests don't use the reporter unless they're going to fail. Change-Id: I7333e2c63ade5e671ebf60022d19390f1fc1c93a Reviewed-on: https://skia-review.googlesource.com/10201 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Brian Salomon <bsalomon@google.com>
* ok: alias 565 -> sw:ct=565Gravatar Mike Klein2017-03-27
| | | | | | | | | | This is mostly a demo, and to make sure it's easy. If I'm thinking right, other non-ct options should Just Work. Change-Id: I295db0fa04921ccdd766e1870e367594ca802462 Reviewed-on: https://skia-review.googlesource.com/10190 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* ok: handle concurrent crashes betterGravatar Mike Klein2017-03-27
| | | | | | | | | | | | | | lockf() is a simple way to prevent interlaced stack traces when there are concurrent crashes. After a crashing process rethrows its signal and dies for real, the OS unlocks the file for other processes. I tested this by making SkCanvas::drawRRect() crash on Linux: 20-odd GM crashes with interlaced stack traces before, none after. Change-Id: I99930756b8c85c552eef7c3a77778e4c00d34c42 Reviewed-on: https://skia-review.googlesource.com/10177 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* ok: refactor Src/Dst interactionsGravatar Mike Klein2017-03-25
| | | | | | | | | | | | | | | | | | | | | | | | This makes everything a lot more like DM, for the same reason: it's the best way to make Vias work. Instead of exposing a canvas, Dsts take a Src to draw. Vias still are Dsts that wrap Dsts. They do their internal work in draw() then pass a proxy Src encapsulating that work to the next Dst's draw(). A little refactoring in ok.cpp allows arbitrary chains of Vias. I removed the guarantee that Src methods are called in strict order. It's easy enough to make each Src initialize itself as needed. I moved the .png encoding back to ok.cpp. It seemed weird for Dsts to have to think about files and paths. One day Dst will want a data() method for non-image output (.pdf, .skp), and then we'll want ok.cpp to be the one to coordinate what to write where. Change-Id: Id4a3674b2d05aef2b5f10e0077df0a8407c07b61 Reviewed-on: https://skia-review.googlesource.com/10175 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
* ok: basic ViasGravatar Mike Klein2017-03-25
| | | | | | | | | | Not sure if these simple Src/Dst interfaces will last. Vias are a little tricky, and some may be impossible. Change-Id: I42d19b1ee74b51a830bb781f25a888c0b32ba98c Reviewed-on: https://skia-review.googlesource.com/10174 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
* Spin off non-core parts of ok into their own files.Gravatar Mike Klein2017-03-25
| | | | | | | | | | | | Now ok.cpp handles only the high level coordination of Srcs and Dsts, without having to know or care what they are. Some minor refactoring to things like Options. Change-Id: I02df890b26d6d069e980a125b6a1ce1a7067b900 Reviewed-on: https://skia-review.googlesource.com/10173 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
* ok: introduce the idea of DstsGravatar Mike Klein2017-03-24
| | | | | | | Change-Id: I47ac01f0c2c0f2f7b925de09c18d3c8265398c8a Reviewed-on: https://skia-review.googlesource.com/10117 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* ok: fix an assert from unbalanced save/restoresGravatar Mike Klein2017-03-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The 'dont_clip_to_layer' GM does not balance its layers. It calls saveLayer() 3x but restore() only 2x. This may be a bug in the GM itself, but I'm not sure so I haven't changed it here. If ok is writing .pngs, the surface passes ownership of its buffer to an image snapshot, simply marking it as immutable. Then, when the surface is destroyed later, it destroys its inner canvas, which restores its save stack to zero, actually doing some drawing in the case of unbalanced saveLayer()s. We then call notifyPixelsChanged() and hit an assert saying "you just wrote some pixels but this buffer was marked immutable." DM doesn't show this problem because it's doesn't really use surfaces and images, just bitmaps. There's no ownership handoff and nothing is ever immutable, so the condition triggering the assert never comes up. I'm not really sure where we want to say is the bug: - SkCanvas can draw in its destructor? - SkSurface doesn't restore to zero before snapping an image? - that dont_clip_to_layer should call restore three times? In any case, this guards against it in ok. I was using this as a convenient crash to help figure out how to best save and print stack traces, but now that I've got that worked out we might as well fix this. Change-Id: Id6d397f534dd1b50219e0d3078c989a4910883a6 Reviewed-on: https://skia-review.googlesource.com/10140 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* ok: basic crash handling and stack trace dumpsGravatar Mike Klein2017-03-24
| | | | | | | | | | | | | | | This seems to work pretty nicely for each engine in the expected case of few crashes. The serial and thread engines just dump the first crash stack to stderr before dying, while the fork engine saves all crashes to a temporary file, then prints that to stderr once everything's finished. I'm not sold on this TLS solution as being the best way to know what was running when we crashed, but it's better than printing nothing. Change-Id: I0aca66529301b1ad9bd51ec728848817586c606d Reviewed-on: https://skia-review.googlesource.com/10102 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* Improve TaskEngine::wait_one().Gravatar Mike Klein2017-03-23
| | | | | | | | | This runs much faster. Very good idea. Change-Id: I088aa9588c069a17e4745be55c2397114ee8a2bc Reviewed-on: https://skia-review.googlesource.com/10053 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* okGravatar Mike Klein2017-03-23
Change-Id: I9d01656a9d9b7aa3ab352dd4c168b26da620a903 Reviewed-on: https://skia-review.googlesource.com/9978 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>